# Set working directory to where csv file is located
#setwd("C:")

mydata<- read.csv("CleanData_Final_Revision.csv")
attach(mydata)
labels(mydata)
obs<-length(mydata$Subject)
# names(mydata)[1] <- "Sess"
# only once:
install.packages("ggplot2")
install.packages('plyr')
install.packages('gridExtra')
install.packages("qqman")
install.packages("stargazer")
#SeqBin
Sys.setenv(LIBGL_ALWAYS_SOFTWARE=1)
install.packages("plotly")
install.packages("ggtern")
install.packages("ggarrange")
install.packages("GGally")
install.packages("VGAM")

library(stargazer)
library(plyr)
library(ggplot2)
library(gridExtra)
library(qqman)
library(glmulti)
library(SparseM)
library(MatrixModels)
library(censReg)
library(grid)
library(Hmisc)
library(lme4)
library(datdum)
library(lmerTest)
library(psych)
library(plotly)
library(ggtern)
library(mlogit)
library(gmnl)
library(nnet)
library(GGally)
library(VGAM)

NumObsControl <- 1735
NumObsFine <- 1703
NumObsAssoc <- 1457
NumObsPun <- 1854
NumObsTotal<- NumObsControl+NumObsFine+NumObsAssoc+NumObsPun

#FastOrNot is a 1x6749 vector
FastOrNot<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  FastOrNot[count]<-ifelse(mydata$DrivingChoice.1.[i]==3, 1, 0)
  FastOrNot[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==3, 1, 0)
  FastOrNot[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==3, 1, 0)
  FastOrNot[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==3, 1, 0)
  FastOrNot[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==3, 1, 0)
  FastOrNot[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==3, 1, 0)
  FastOrNot[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==3, 1, 0)
  FastOrNot[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==3, 1, 0)
  FastOrNot[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==3, 1, 0)
  FastOrNot[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==3, 1, 0)
  FastOrNot[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==3, 1, 0)
  FastOrNot[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==3, 1, 0)
  FastOrNot[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==3, 1, 0)
  FastOrNot[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==3, 1, 0)
  FastOrNot[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==3, 1, 0)
  FastOrNot[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==3, 1, 0)
  FastOrNot[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==3, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){FastOrNot[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==3, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){FastOrNot[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==3, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){FastOrNot[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==3, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){FastOrNot[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==3, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){FastOrNot[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==3, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){FastOrNot[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==3, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){FastOrNot[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==3, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){FastOrNot[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==3, 1, 0) 
  jump<-25}
  count<-count+jump
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
FastOrNot <- FastOrNot[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(FastOrNot, 50)
table(FastOrNot)



#AutoOrNot is a 1x6749 vector
AutoOrNot<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  AutoOrNot[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 1, 0)
  AutoOrNot[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 1, 0)
  AutoOrNot[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 1, 0)
  AutoOrNot[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 1, 0)
  AutoOrNot[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 1, 0)
  AutoOrNot[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 1, 0)
  AutoOrNot[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 1, 0)
  AutoOrNot[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 1, 0)
  AutoOrNot[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 1, 0)
  AutoOrNot[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 1, 0)
  AutoOrNot[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 1, 0)
  AutoOrNot[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 1, 0)
  AutoOrNot[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 1, 0)
  AutoOrNot[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 1, 0)
  AutoOrNot[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 1, 0)
  AutoOrNot[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 1, 0)
  AutoOrNot[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoOrNot[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoOrNot[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoOrNot[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoOrNot[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoOrNot[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoOrNot[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoOrNot[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoOrNot[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 1, 0) 
  jump<-25}
  count<-count+jump
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
AutoOrNot <- AutoOrNot[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(AutoOrNot, 50)
table(AutoOrNot)

#SlowOrNot is a 1x6749 vector
SlowOrNot<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  SlowOrNot[count]<-ifelse(mydata$DrivingChoice.1.[i]==2, 1, 0)
  SlowOrNot[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==2, 1, 0)
  SlowOrNot[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==2, 1, 0)
  SlowOrNot[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==2, 1, 0)
  SlowOrNot[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==2, 1, 0)
  SlowOrNot[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==2, 1, 0)
  SlowOrNot[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==2, 1, 0)
  SlowOrNot[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==2, 1, 0)
  SlowOrNot[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==2, 1, 0)
  SlowOrNot[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==2, 1, 0)
  SlowOrNot[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==2, 1, 0)
  SlowOrNot[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==2, 1, 0)
  SlowOrNot[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==2, 1, 0)
  SlowOrNot[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==2, 1, 0)
  SlowOrNot[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==2, 1, 0)
  SlowOrNot[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==2, 1, 0)
  SlowOrNot[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==2, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SlowOrNot[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==2, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SlowOrNot[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==2, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SlowOrNot[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==2, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SlowOrNot[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==2, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SlowOrNot[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==2, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SlowOrNot[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==2, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SlowOrNot[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==2, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SlowOrNot[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==2, 1, 0) 
  jump<-25}
  count<-count+jump
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
SlowOrNot <- SlowOrNot[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(SlowOrNot, 50)
table(SlowOrNot)

#AutoFastSlow is a 1x6749 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlow<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  AutoFastSlow[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlow[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlow[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlow[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlow[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlow[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlow[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlow[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlow[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlow[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlow[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlow[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlow[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlow[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlow[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlow[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlow[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlow[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlow[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlow[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlow[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlow[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlow[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlow[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlow[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
tail(AutoFastSlow, 46)
table(AutoFastSlow)

#Change numbers to names (Auto=0)
for(i in 1:NumObsTotal){ifelse(AutoFastSlow[i]==1, AutoFastSlow[i]<-'Fast', ifelse(AutoFastSlow[i]==2, AutoFastSlow[i]<-'Slow', AutoFastSlow[i]<-0))}
#Change numbers to names (Fast=0)
for(i in 1:NumObsTotal){ifelse(AutoFastSlow[i]==1, AutoFastSlow[i]<-0, ifelse(AutoFastSlow[i]==2, AutoFastSlow[i]<-'Slow', AutoFastSlow[i]<-'Auto'))}
#Change numbers to names (Slow=0)
for(i in 1:NumObsTotal){ifelse(AutoFastSlow[i]==1, AutoFastSlow[i]<-'Fast', ifelse(AutoFastSlow[i]==2, AutoFastSlow[i]<-0, AutoFastSlow[i]<-'Auto'))}


#Check the driving choice of a subject in the [subject number]
x<-325
mydata$DrivingChoice.1.[x]
mydata$DrivingChoice.2.[x]
mydata$DrivingChoice.3.[x]
mydata$DrivingChoice.4.[x]
mydata$DrivingChoice.5.[x]
mydata$DrivingChoice.6.[x]
mydata$DrivingChoice.7.[x]
mydata$DrivingChoice.8.[x]
mydata$DrivingChoice.9.[x]
mydata$DrivingChoice.10.[x]
mydata$DrivingChoice.11.[x]
mydata$DrivingChoice.12.[x]
mydata$DrivingChoice.13.[x]
mydata$DrivingChoice.14.[x]
mydata$DrivingChoice.15.[x]
mydata$DrivingChoice.16.[x]
mydata$DrivingChoice.17.[x]
mydata$DrivingChoice.18.[x]
mydata$DrivingChoice.19.[x]
mydata$DrivingChoice.20.[x]
mydata$DrivingChoice.21.[x]
mydata$DrivingChoice.22.[x]
mydata$DrivingChoice.23.[x]
mydata$DrivingChoice.24.[x]
mydata$DrivingChoice.25.[x]



#SessNum is a 1x6749 vector
SessNum<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  SessNum[count]<-mydata$Sess[i]
  SessNum[count+1]<-mydata$Sess[i]
  SessNum[count+2]<-mydata$Sess[i]
  SessNum[count+3]<-mydata$Sess[i]
  SessNum[count+4]<-mydata$Sess[i]
  SessNum[count+5]<-mydata$Sess[i]
  SessNum[count+6]<-mydata$Sess[i]
  SessNum[count+7]<-mydata$Sess[i]
  SessNum[count+8]<-mydata$Sess[i]
  SessNum[count+9]<-mydata$Sess[i]
  SessNum[count+10]<-mydata$Sess[i]
  SessNum[count+11]<-mydata$Sess[i]
  SessNum[count+12]<-mydata$Sess[i]
  SessNum[count+13]<-mydata$Sess[i]
  SessNum[count+14]<-mydata$Sess[i]
  SessNum[count+15]<-mydata$Sess[i]
  SessNum[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNum[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNum[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNum[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNum[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNum[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNum[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNum[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNum[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
tail(SessNum, 50)
table(SessNum)

SessNumC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  SessNumC[count]<-mydata$Sess[i]
  SessNumC[count+1]<-mydata$Sess[i]
  SessNumC[count+2]<-mydata$Sess[i]
  SessNumC[count+3]<-mydata$Sess[i]
  SessNumC[count+4]<-mydata$Sess[i]
  SessNumC[count+5]<-mydata$Sess[i]
  SessNumC[count+6]<-mydata$Sess[i]
  SessNumC[count+7]<-mydata$Sess[i]
  SessNumC[count+8]<-mydata$Sess[i]
  SessNumC[count+9]<-mydata$Sess[i]
  SessNumC[count+10]<-mydata$Sess[i]
  SessNumC[count+11]<-mydata$Sess[i]
  SessNumC[count+12]<-mydata$Sess[i]
  SessNumC[count+13]<-mydata$Sess[i]
  SessNumC[count+14]<-mydata$Sess[i]
  SessNumC[count+15]<-mydata$Sess[i]
  SessNumC[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNumC[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNumC[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNumC[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNumC[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNumC[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNumC[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNumC[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNumC[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
}
tail(SessNumC, 50)
table(SessNumC)


SessNumF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  SessNumF[count]<-mydata$Sess[i]
  SessNumF[count+1]<-mydata$Sess[i]
  SessNumF[count+2]<-mydata$Sess[i]
  SessNumF[count+3]<-mydata$Sess[i]
  SessNumF[count+4]<-mydata$Sess[i]
  SessNumF[count+5]<-mydata$Sess[i]
  SessNumF[count+6]<-mydata$Sess[i]
  SessNumF[count+7]<-mydata$Sess[i]
  SessNumF[count+8]<-mydata$Sess[i]
  SessNumF[count+9]<-mydata$Sess[i]
  SessNumF[count+10]<-mydata$Sess[i]
  SessNumF[count+11]<-mydata$Sess[i]
  SessNumF[count+12]<-mydata$Sess[i]
  SessNumF[count+13]<-mydata$Sess[i]
  SessNumF[count+14]<-mydata$Sess[i]
  SessNumF[count+15]<-mydata$Sess[i]
  SessNumF[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNumF[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNumF[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNumF[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNumF[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNumF[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNumF[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNumF[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNumF[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
}
tail(SessNumF, 50)
table(SessNumF)


SessNumA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  SessNumA[count]<-mydata$Sess[i]
  SessNumA[count+1]<-mydata$Sess[i]
  SessNumA[count+2]<-mydata$Sess[i]
  SessNumA[count+3]<-mydata$Sess[i]
  SessNumA[count+4]<-mydata$Sess[i]
  SessNumA[count+5]<-mydata$Sess[i]
  SessNumA[count+6]<-mydata$Sess[i]
  SessNumA[count+7]<-mydata$Sess[i]
  SessNumA[count+8]<-mydata$Sess[i]
  SessNumA[count+9]<-mydata$Sess[i]
  SessNumA[count+10]<-mydata$Sess[i]
  SessNumA[count+11]<-mydata$Sess[i]
  SessNumA[count+12]<-mydata$Sess[i]
  SessNumA[count+13]<-mydata$Sess[i]
  SessNumA[count+14]<-mydata$Sess[i]
  SessNumA[count+15]<-mydata$Sess[i]
  SessNumA[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNumA[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNumA[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNumA[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNumA[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNumA[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNumA[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNumA[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNumA[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
}
tail(SessNumA, 50)
table(SessNumA)


SessNumAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 | mydata$ExpType[i]==3 | mydata$ExpType[i]==4){
  SessNumAny[count]<-mydata$Sess[i]
  SessNumAny[count+1]<-mydata$Sess[i]
  SessNumAny[count+2]<-mydata$Sess[i]
  SessNumAny[count+3]<-mydata$Sess[i]
  SessNumAny[count+4]<-mydata$Sess[i]
  SessNumAny[count+5]<-mydata$Sess[i]
  SessNumAny[count+6]<-mydata$Sess[i]
  SessNumAny[count+7]<-mydata$Sess[i]
  SessNumAny[count+8]<-mydata$Sess[i]
  SessNumAny[count+9]<-mydata$Sess[i]
  SessNumAny[count+10]<-mydata$Sess[i]
  SessNumAny[count+11]<-mydata$Sess[i]
  SessNumAny[count+12]<-mydata$Sess[i]
  SessNumAny[count+13]<-mydata$Sess[i]
  SessNumAny[count+14]<-mydata$Sess[i]
  SessNumAny[count+15]<-mydata$Sess[i]
  SessNumAny[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNumAny[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNumAny[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNumAny[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNumAny[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNumAny[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNumAny[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNumAny[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNumAny[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
}
tail(SessNumAny, 50)
table(SessNumAny)


SessNumP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  SessNumP[count]<-mydata$Sess[i]
  SessNumP[count+1]<-mydata$Sess[i]
  SessNumP[count+2]<-mydata$Sess[i]
  SessNumP[count+3]<-mydata$Sess[i]
  SessNumP[count+4]<-mydata$Sess[i]
  SessNumP[count+5]<-mydata$Sess[i]
  SessNumP[count+6]<-mydata$Sess[i]
  SessNumP[count+7]<-mydata$Sess[i]
  SessNumP[count+8]<-mydata$Sess[i]
  SessNumP[count+9]<-mydata$Sess[i]
  SessNumP[count+10]<-mydata$Sess[i]
  SessNumP[count+11]<-mydata$Sess[i]
  SessNumP[count+12]<-mydata$Sess[i]
  SessNumP[count+13]<-mydata$Sess[i]
  SessNumP[count+14]<-mydata$Sess[i]
  SessNumP[count+15]<-mydata$Sess[i]
  SessNumP[count+16]<-mydata$Sess[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SessNumP[count+17]<-mydata$Sess[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SessNumP[count+18]<-mydata$Sess[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SessNumP[count+19]<-mydata$Sess[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SessNumP[count+20]<-mydata$Sess[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SessNumP[count+21]<-mydata$Sess[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SessNumP[count+22]<-mydata$Sess[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SessNumP[count+23]<-mydata$Sess[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SessNumP[count+24]<-mydata$Sess[i] 
  jump<-25}
  count<-count+jump
}
}
tail(SessNumP, 50)
table(SessNumP)


PropFemaleF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  PropFemaleF[count]<-mydata$PropFemale[i]
  PropFemaleF[count+1]<-mydata$PropFemale[i]
  PropFemaleF[count+2]<-mydata$PropFemale[i]
  PropFemaleF[count+3]<-mydata$PropFemale[i]
  PropFemaleF[count+4]<-mydata$PropFemale[i]
  PropFemaleF[count+5]<-mydata$PropFemale[i]
  PropFemaleF[count+6]<-mydata$PropFemale[i]
  PropFemaleF[count+7]<-mydata$PropFemale[i]
  PropFemaleF[count+8]<-mydata$PropFemale[i]
  PropFemaleF[count+9]<-mydata$PropFemale[i]
  PropFemaleF[count+10]<-mydata$PropFemale[i]
  PropFemaleF[count+11]<-mydata$PropFemale[i]
  PropFemaleF[count+12]<-mydata$PropFemale[i]
  PropFemaleF[count+13]<-mydata$PropFemale[i]
  PropFemaleF[count+14]<-mydata$PropFemale[i]
  PropFemaleF[count+15]<-mydata$PropFemale[i]
  PropFemaleF[count+16]<-mydata$PropFemale[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PropFemaleF[count+17]<-mydata$PropFemale[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PropFemaleF[count+18]<-mydata$PropFemale[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PropFemaleF[count+19]<-mydata$PropFemale[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PropFemaleF[count+20]<-mydata$PropFemale[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PropFemaleF[count+21]<-mydata$PropFemale[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PropFemaleF[count+22]<-mydata$PropFemale[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PropFemaleF[count+23]<-mydata$PropFemale[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PropFemaleF[count+24]<-mydata$PropFemale[i] 
  jump<-25}
  count<-count+jump
}
}
tail(PropFemaleF, 50)
table(PropFemaleF)


PropFemaleC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PropFemaleC[count]<-mydata$PropFemale[i]
  PropFemaleC[count+1]<-mydata$PropFemale[i]
  PropFemaleC[count+2]<-mydata$PropFemale[i]
  PropFemaleC[count+3]<-mydata$PropFemale[i]
  PropFemaleC[count+4]<-mydata$PropFemale[i]
  PropFemaleC[count+5]<-mydata$PropFemale[i]
  PropFemaleC[count+6]<-mydata$PropFemale[i]
  PropFemaleC[count+7]<-mydata$PropFemale[i]
  PropFemaleC[count+8]<-mydata$PropFemale[i]
  PropFemaleC[count+9]<-mydata$PropFemale[i]
  PropFemaleC[count+10]<-mydata$PropFemale[i]
  PropFemaleC[count+11]<-mydata$PropFemale[i]
  PropFemaleC[count+12]<-mydata$PropFemale[i]
  PropFemaleC[count+13]<-mydata$PropFemale[i]
  PropFemaleC[count+14]<-mydata$PropFemale[i]
  PropFemaleC[count+15]<-mydata$PropFemale[i]
  PropFemaleC[count+16]<-mydata$PropFemale[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PropFemaleC[count+17]<-mydata$PropFemale[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PropFemaleC[count+18]<-mydata$PropFemale[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PropFemaleC[count+19]<-mydata$PropFemale[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PropFemaleC[count+20]<-mydata$PropFemale[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PropFemaleC[count+21]<-mydata$PropFemale[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PropFemaleC[count+22]<-mydata$PropFemale[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PropFemaleC[count+23]<-mydata$PropFemale[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PropFemaleC[count+24]<-mydata$PropFemale[i] 
  jump<-25}
  count<-count+jump
}
}
tail(PropFemaleC, 50)
table(PropFemaleC)

PropFemaleA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  PropFemaleA[count]<-mydata$PropFemale[i]
  PropFemaleA[count+1]<-mydata$PropFemale[i]
  PropFemaleA[count+2]<-mydata$PropFemale[i]
  PropFemaleA[count+3]<-mydata$PropFemale[i]
  PropFemaleA[count+4]<-mydata$PropFemale[i]
  PropFemaleA[count+5]<-mydata$PropFemale[i]
  PropFemaleA[count+6]<-mydata$PropFemale[i]
  PropFemaleA[count+7]<-mydata$PropFemale[i]
  PropFemaleA[count+8]<-mydata$PropFemale[i]
  PropFemaleA[count+9]<-mydata$PropFemale[i]
  PropFemaleA[count+10]<-mydata$PropFemale[i]
  PropFemaleA[count+11]<-mydata$PropFemale[i]
  PropFemaleA[count+12]<-mydata$PropFemale[i]
  PropFemaleA[count+13]<-mydata$PropFemale[i]
  PropFemaleA[count+14]<-mydata$PropFemale[i]
  PropFemaleA[count+15]<-mydata$PropFemale[i]
  PropFemaleA[count+16]<-mydata$PropFemale[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PropFemaleA[count+17]<-mydata$PropFemale[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PropFemaleA[count+18]<-mydata$PropFemale[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PropFemaleA[count+19]<-mydata$PropFemale[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PropFemaleA[count+20]<-mydata$PropFemale[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PropFemaleA[count+21]<-mydata$PropFemale[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PropFemaleA[count+22]<-mydata$PropFemale[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PropFemaleA[count+23]<-mydata$PropFemale[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PropFemaleA[count+24]<-mydata$PropFemale[i] 
  jump<-25}
  count<-count+jump
}
}
tail(PropFemaleA, 50)
table(PropFemaleA)


PropFemaleP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PropFemaleP[count]<-mydata$PropFemale[i]
  PropFemaleP[count+1]<-mydata$PropFemale[i]
  PropFemaleP[count+2]<-mydata$PropFemale[i]
  PropFemaleP[count+3]<-mydata$PropFemale[i]
  PropFemaleP[count+4]<-mydata$PropFemale[i]
  PropFemaleP[count+5]<-mydata$PropFemale[i]
  PropFemaleP[count+6]<-mydata$PropFemale[i]
  PropFemaleP[count+7]<-mydata$PropFemale[i]
  PropFemaleP[count+8]<-mydata$PropFemale[i]
  PropFemaleP[count+9]<-mydata$PropFemale[i]
  PropFemaleP[count+10]<-mydata$PropFemale[i]
  PropFemaleP[count+11]<-mydata$PropFemale[i]
  PropFemaleP[count+12]<-mydata$PropFemale[i]
  PropFemaleP[count+13]<-mydata$PropFemale[i]
  PropFemaleP[count+14]<-mydata$PropFemale[i]
  PropFemaleP[count+15]<-mydata$PropFemale[i]
  PropFemaleP[count+16]<-mydata$PropFemale[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PropFemaleP[count+17]<-mydata$PropFemale[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PropFemaleP[count+18]<-mydata$PropFemale[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PropFemaleP[count+19]<-mydata$PropFemale[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PropFemaleP[count+20]<-mydata$PropFemale[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PropFemaleP[count+21]<-mydata$PropFemale[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PropFemaleP[count+22]<-mydata$PropFemale[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PropFemaleP[count+23]<-mydata$PropFemale[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PropFemaleP[count+24]<-mydata$PropFemale[i] 
  jump<-25}
  count<-count+jump
}
}
tail(PropFemaleP, 50)
table(PropFemaleP)



PropFemaleAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 | mydata$ExpType[i]==3 | mydata$ExpType[i]==4){
  PropFemaleAny[count]<-mydata$PropFemale[i]
  PropFemaleAny[count+1]<-mydata$PropFemale[i]
  PropFemaleAny[count+2]<-mydata$PropFemale[i]
  PropFemaleAny[count+3]<-mydata$PropFemale[i]
  PropFemaleAny[count+4]<-mydata$PropFemale[i]
  PropFemaleAny[count+5]<-mydata$PropFemale[i]
  PropFemaleAny[count+6]<-mydata$PropFemale[i]
  PropFemaleAny[count+7]<-mydata$PropFemale[i]
  PropFemaleAny[count+8]<-mydata$PropFemale[i]
  PropFemaleAny[count+9]<-mydata$PropFemale[i]
  PropFemaleAny[count+10]<-mydata$PropFemale[i]
  PropFemaleAny[count+11]<-mydata$PropFemale[i]
  PropFemaleAny[count+12]<-mydata$PropFemale[i]
  PropFemaleAny[count+13]<-mydata$PropFemale[i]
  PropFemaleAny[count+14]<-mydata$PropFemale[i]
  PropFemaleAny[count+15]<-mydata$PropFemale[i]
  PropFemaleAny[count+16]<-mydata$PropFemale[i]
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PropFemaleAny[count+17]<-mydata$PropFemale[i] 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PropFemaleAny[count+18]<-mydata$PropFemale[i] 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PropFemaleAny[count+19]<-mydata$PropFemale[i] 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PropFemaleAny[count+20]<-mydata$PropFemale[i] 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PropFemaleAny[count+21]<-mydata$PropFemale[i] 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PropFemaleAny[count+22]<-mydata$PropFemale[i] 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PropFemaleAny[count+23]<-mydata$PropFemale[i] 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PropFemaleAny[count+24]<-mydata$PropFemale[i] 
  jump<-25}
  count<-count+jump
}
}
tail(PropFemaleAny, 50)
table(PropFemaleAny)


#FineDummy is a 1x6749 vector
FineDummy<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  FineDummy[count]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+1]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+2]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+3]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+4]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+5]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+6]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+7]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+8]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+9]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+10]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+11]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+12]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+13]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+14]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+15]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  FineDummy[count+16]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){FineDummy[count+17]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){FineDummy[count+18]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){FineDummy[count+19]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){FineDummy[count+20]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){FineDummy[count+21]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){FineDummy[count+22]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){FineDummy[count+23]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){FineDummy[count+24]<-ifelse(mydata$ExpType[i]==2, 1, 0)
  jump<-25}
  count<-count+jump
}

table(FineDummy)

#AssocDummy is a 1x6749 vector
AssocDummy<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  AssocDummy[count]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+1]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+2]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+3]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+4]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+5]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+6]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+7]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+8]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+9]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+10]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+11]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+12]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+13]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+14]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+15]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  AssocDummy[count+16]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AssocDummy[count+17]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AssocDummy[count+18]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AssocDummy[count+19]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AssocDummy[count+20]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AssocDummy[count+21]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AssocDummy[count+22]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AssocDummy[count+23]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AssocDummy[count+24]<-ifelse(mydata$ExpType[i]==3, 1, 0)
  jump<-25}
  count<-count+jump
}
table(AssocDummy)


#PunDummy is a 1x6749 vector
PunDummy<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PunDummy[count]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+1]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+2]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+3]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+4]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+5]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+6]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+7]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+8]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+9]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+10]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+11]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+12]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+13]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+14]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+15]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  PunDummy[count+16]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PunDummy[count+17]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PunDummy[count+18]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PunDummy[count+19]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PunDummy[count+20]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PunDummy[count+21]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PunDummy[count+22]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PunDummy[count+23]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PunDummy[count+24]<-ifelse(mydata$ExpType[i]==4, 1, 0)
  jump<-25}
  count<-count+jump
}
table(PunDummy)

probitfitFast<- glm(FastOrNot~FineDummy + AssocDummy + PunDummy, family = binomial(link = "probit"))
summary(probitfitFast)

probitfitAuto<- glm(AutoOrNot~FineDummy + AssocDummy + PunDummy, family = binomial(link = "probit"))
summary(probitfitAuto)

probitfitSlow<- glm(SlowOrNot~FineDummy + AssocDummy + PunDummy, family = binomial(link = "probit"))
summary(probitfitSlow)

# Multinomial logit
data1<-data.frame(AutoFastSlow, FineDummy,AssocDummy,PunDummy)
MLdata <- mlogit.data(data1, choice = "AutoFastSlow", shape = "wide", alt.levels = c("0", "1", "2"))
mlogitfit<- gmnl(AutoFastSlow~FineDummy + AssocDummy + PunDummy, data=MLdata)
gFormula(MLdata)

### using multinom
data1<-data.frame(AutoFastSlow, FineDummy,AssocDummy,PunDummy)
mlogitfit2<- multinom(AutoFastSlow~FineDummy + AssocDummy + PunDummy, data=data1)
summary(mlogitfit2)
z <- summary(mlogitfit2)$coefficients/summary(mlogitfit2)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p

#Come back here when I have other variables.
head(pp <- fitted(mlogitfit2))

### using Tobit Censored at 0 to explain beliefs by dummies Tobit and linear model are the same for Fast beliefs
data1<-data.frame(FastBelief, FineDummy,AssocDummy,PunDummy,Sex,StudentType, Risk,Learning,PrevEarn)
#BeliefFitF<- vglm(FastBelief~FineDummy + AssocDummy + PunDummy, family = tobit(Lower=0), data=data1)
BeliefFitF<- lm(FastBelief~FineDummy + AssocDummy + PunDummy+Sex+StudentType+ Risk+Learning+PrevEarn, data=data1)
summary(BeliefFitF)

### using Tobit Censored at 0 to explain beliefs by dummies Tobit and linear model are the same for Slow beliefs

data1<-data.frame(SlowBelief, FineDummy,AssocDummy,PunDummy,Sex,StudentType, Risk,Learning,PrevEarn)
#BeliefFitS<- vglm(SlowBelief~FineDummy + AssocDummy + PunDummy, family = tobit(Lower=0), data=data1)
BeliefFitS<- lm(SlowBelief~FineDummy + AssocDummy + PunDummy+Sex+StudentType+ Risk+Learning+PrevEarn, data=data1)
summary(BeliefFitS)

### using Tobit Censored at 0 to explain beliefs by dummies Tobit and linear model are the same for Auto beliefs
data1<-data.frame(AutoBelief, FineDummy,AssocDummy,PunDummy,Sex,StudentType, Risk,Learning,PrevEarn)
#BeliefFitA<- vglm(AutoBelief~FineDummy + AssocDummy + PunDummy, family = tobit(Lower=0), data=data1)
BeliefFitA<- lm(AutoBelief~FineDummy + AssocDummy + PunDummy+Sex+StudentType+ Risk+Learning+PrevEarn, data=data1)
summary(BeliefFitA)

#Stargazer doesn't work for tobit
stargazer(BeliefFitF,BeliefFitS,BeliefFitA)
stargazer(BeliefFitF,BeliefFitS,BeliefFitA, title="Baseline + Controls", report=('vc*p'))


#Are the guesses more accurate in different treatments?

mean(GuessAccC)
mean(GuessAccF)
mean(GuessAccA)
mean(GuessAccP)

t.test(GuessAccC, GuessAccF)
t.test(GuessAccC, GuessAccA)
t.test(GuessAccF, GuessAccP)

### using Tobit Censored at 0 to explain GuessAccuracy by dummies Tobit and linear model are the same for Auto beliefs
data1<-data.frame(GuessAcc, FineDummy,AssocDummy,PunDummy,Sex,StudentType, Risk,Learning,PrevEarn)
AccFit<- vglm(GuessAcc~FineDummy + AssocDummy + PunDummy+Sex+StudentType+ Risk+Learning+PrevEarn, family = tobit(Lower=0, Upper=5), data=data1)
#AccFit<- lm(GuessAcc~FineDummy + AssocDummy + PunDummy+Sex+StudentType+ Risk+Learning+PrevEarn, data=data1)
summary(AccFit)
#Guess accuracy takes into account all three variables at once. We want to see how close they were in guessing Fast, how close in Slow and how close in Auto.

#Round number vector

#How do people make decisions in the control environment?

#AutoFastSLowC is a 1x1735 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  AutoFastSlowC[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowC[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowC[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowC[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowC[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowC[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowC[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowC[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowC[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowC[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowC[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowC[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowC[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowC[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowC[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowC[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowC[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowC[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowC[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowC[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowC[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowC[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowC[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowC[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowC[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowC, 46)
table(AutoFastSlowC)

AutoFastSlowCF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==2){
  AutoFastSlowCF[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowCF[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowCF[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowCF[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowCF[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowCF[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowCF[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowCF[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowCF[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowCF[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowCF[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowCF[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowCF[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowCF[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowCF[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowCF[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowCF[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowCF[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowCF[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowCF[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowCF[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowCF[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowCF[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowCF[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowCF[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowCF, 46)
table(AutoFastSlowCF)


AutoFastSlowCM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==1){
  AutoFastSlowCM[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowCM[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowCM[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowCM[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowCM[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowCM[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowCM[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowCM[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowCM[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowCM[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowCM[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowCM[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowCM[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowCM[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowCM[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowCM[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowCM[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowCM[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowCM[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowCM[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowCM[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowCM[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowCM[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowCM[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowCM[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowCM, 46)
t<-table(AutoFastSlowCM)
prop.table(t) 

t<-table(AutoFastSlowCF)
prop.table(t) 


t.test(AutoFastSlowCF,AutoFastSlowCM)


#Change numbers to names (Auto=0)
#for(i in 1:NumObsControl){ifelse(AutoFastSlowC[i]==1, AutoFastSlowC[i]<-'Fast', ifelse(AutoFastSlowC[i]==2, AutoFastSlowC[i]<-'Slow', AutoFastSlowC[i]<-0))}
#Change numbers to names (Fast=0)
#for(i in 1:NumObsControl){ifelse(AutoFastSlowC[i]==1, AutoFastSlowC[i]<-0, ifelse(AutoFastSlowC[i]==2, AutoFastSlowC[i]<-'Slow', AutoFastSlowC[i]<-'Auto'))}
#Change numbers to names (Slow=0)
for(i in 1:NumObsControl){ifelse(AutoFastSlowC[i]==1, AutoFastSlowC[i]<-'Fast', ifelse(AutoFastSlowC[i]==2, AutoFastSlowC[i]<-0, AutoFastSlowC[i]<-'Auto'))}

table

#DecTimeC is a 1x1735 vector 
DecTimeC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  DecTimeC[count]<-mydata$DecTime.1.[i]
  DecTimeC[count+1]<-mydata$DecTime.2.[i]
  DecTimeC[count+2]<-mydata$DecTime.3.[i]
  DecTimeC[count+3]<-mydata$DecTime.4.[i]
  DecTimeC[count+4]<-mydata$DecTime.5.[i]
  DecTimeC[count+5]<-mydata$DecTime.6.[i]
  DecTimeC[count+6]<-mydata$DecTime.7.[i]
  DecTimeC[count+7]<-mydata$DecTime.8.[i]
  DecTimeC[count+8]<-mydata$DecTime.9.[i]
  DecTimeC[count+9]<-mydata$DecTime.10.[i]
  DecTimeC[count+10]<-mydata$DecTime.11.[i]
  DecTimeC[count+11]<-mydata$DecTime.12.[i]
  DecTimeC[count+12]<-mydata$DecTime.13.[i]
  DecTimeC[count+13]<-mydata$DecTime.14.[i]
  DecTimeC[count+14]<-mydata$DecTime.15.[i]
  DecTimeC[count+15]<-mydata$DecTime.16.[i]
  DecTimeC[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeC[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeC[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeC[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeC[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeC[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeC[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeC[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeC[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#DecTimeC <- DecTimeC[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(DecTimeC, 46)
table(DecTimeC)


#FastBeliefC is a 1x1735 vector 
FastBeliefC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  FastBeliefC[count]<-mydata$GuessFast.1.[i]
  FastBeliefC[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefC[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefC[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefC[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefC[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefC[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefC[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefC[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefC[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefC[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefC[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefC[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefC[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefC[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefC[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefC[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefC[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefC[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefC[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefC[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefC[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefC[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefC[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefC[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(FastBeliefC, 46)
table(FastBeliefC)

#SlowBeliefC is a 1x1735 vector 
SlowBeliefC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  SlowBeliefC[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefC[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefC[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefC[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefC[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefC[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefC[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefC[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefC[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefC[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefC[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefC[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefC[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefC[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefC[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefC[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefC[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefC[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefC[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefC[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefC[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefC[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefC[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefC[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefC[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(SlowBeliefC, 46)
table(SlowBeliefC)

#AutoBeliefC is a 1x1735 vector 
AutoBeliefC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  AutoBeliefC[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefC[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefC[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefC[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefC[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefC[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefC[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefC[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefC[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefC[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefC[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefC[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefC[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefC[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefC[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefC[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefC[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefC[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefC[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefC[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefC[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefC[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefC[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefC[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefC[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(AutoBeliefC, 46)
table(AutoBeliefC)


#PrevEarnC is a  vector 
PrevEarnC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PrevEarnC[count]<-0
  PrevEarnC[count+1]<-mydata$ChoicePayoff.1.[i]
  PrevEarnC[count+2]<-mydata$ChoicePayoff.2.[i]
  PrevEarnC[count+3]<-mydata$ChoicePayoff.3.[i]
  PrevEarnC[count+4]<-mydata$ChoicePayoff.4.[i]
  PrevEarnC[count+5]<-mydata$ChoicePayoff.5.[i]
  PrevEarnC[count+6]<-mydata$ChoicePayoff.6.[i]
  PrevEarnC[count+7]<-mydata$ChoicePayoff.7.[i]
  PrevEarnC[count+8]<-mydata$ChoicePayoff.8.[i]
  PrevEarnC[count+9]<-mydata$ChoicePayoff.9.[i]
  PrevEarnC[count+10]<-mydata$ChoicePayoff.10.[i]
  PrevEarnC[count+11]<-mydata$ChoicePayoff.11.[i]
  PrevEarnC[count+12]<-mydata$ChoicePayoff.12.[i]
  PrevEarnC[count+13]<-mydata$ChoicePayoff.13.[i]
  PrevEarnC[count+14]<-mydata$ChoicePayoff.14.[i]
  PrevEarnC[count+15]<-mydata$ChoicePayoff.15.[i]
  PrevEarnC[count+16]<-mydata$ChoicePayoff.16.[i]
  jump<-16
  if(is.na(mydata$ChoicePayoff.17.[i])==FALSE){PrevEarnC[count+17]<-mydata$ChoicePayoff.17.[i]
  jump<-17}
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PrevEarnC[count+18]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PrevEarnC[count+19]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PrevEarnC[count+20]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PrevEarnC[count+21]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PrevEarnC[count+22]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PrevEarnC[count+23]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PrevEarnC[count+24]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PrevEarnC[count+25]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevEarnC<-c(PrevEarnC[1:1735])
tail(PrevEarnC, 38)
table(PrevEarnC)

#PrevAccC is a 1x1735 vector 
PrevAccC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PrevAccC[count]<-0
  PrevAccC[count+1]<-mydata$AccidentHistory.1.[i]
  PrevAccC[count+2]<-mydata$AccidentHistory.2.[i]
  PrevAccC[count+3]<-mydata$AccidentHistory.3.[i]
  PrevAccC[count+4]<-mydata$AccidentHistory.4.[i]
  PrevAccC[count+5]<-mydata$AccidentHistory.5.[i]
  PrevAccC[count+6]<-mydata$AccidentHistory.6.[i]
  PrevAccC[count+7]<-mydata$AccidentHistory.7.[i]
  PrevAccC[count+8]<-mydata$AccidentHistory.8.[i]
  PrevAccC[count+9]<-mydata$AccidentHistory.9.[i]
  PrevAccC[count+10]<-mydata$AccidentHistory.10.[i]
  PrevAccC[count+11]<-mydata$AccidentHistory.11.[i]
  PrevAccC[count+12]<-mydata$AccidentHistory.12.[i]
  PrevAccC[count+13]<-mydata$AccidentHistory.13.[i]
  PrevAccC[count+14]<-mydata$AccidentHistory.14.[i]
  PrevAccC[count+15]<-mydata$AccidentHistory.15.[i]
  PrevAccC[count+16]<-mydata$AccidentHistory.16.[i]
  jump<-16
  if(is.na(mydata$AccidentHistory.17.[i])==FALSE){PrevAccC[count+17]<-mydata$AccidentHistory.17.[i]
  jump<-17}
  if(is.na(mydata$AccidentHistory.18.[i])==FALSE){PrevAccC[count+18]<-mydata$AccidentHistory.18.[i]
  jump<-18}
  if(is.na(mydata$AccidentHistory.19.[i])==FALSE){PrevAccC[count+19]<-mydata$AccidentHistory.19.[i]
  jump<-19}
  if(is.na(mydata$AccidentHistory.20.[i])==FALSE){PrevAccC[count+20]<-mydata$AccidentHistory.20.[i]
  jump<-20}
  if(is.na(mydata$AccidentHistory.21.[i])==FALSE){PrevAccC[count+21]<-mydata$AccidentHistory.21.[i]
  jump<-21}
  if(is.na(mydata$AccidentHistory.22.[i])==FALSE){PrevAccC[count+22]<-mydata$AccidentHistory.22.[i]
  jump<-22}
  if(is.na(mydata$AccidentHistory.23.[i])==FALSE){PrevAccC[count+23]<-mydata$AccidentHistory.23.[i]
  jump<-23}
  if(is.na(mydata$AccidentHistory.24.[i])==FALSE){PrevAccC[count+24]<-mydata$AccidentHistory.24.[i]
  jump<-24}
  if(is.na(mydata$AccidentHistory.25.[i])==FALSE){PrevAccC[count+25]<-mydata$AccidentHistory.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevAccC<-c(PrevAccC[1:1735])
tail(PrevAccC, 38)
table(PrevAccC)

#PrevGuessAccC is a 1x1735 vector 
PrevGuessAccC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PrevGuessAccC[count]<-0
  PrevGuessAccC[count+1]<-mydata$GuessPayoff.1.[i]
  PrevGuessAccC[count+2]<-mydata$GuessPayoff.2.[i]
  PrevGuessAccC[count+3]<-mydata$GuessPayoff.3.[i]
  PrevGuessAccC[count+4]<-mydata$GuessPayoff.4.[i]
  PrevGuessAccC[count+5]<-mydata$GuessPayoff.5.[i]
  PrevGuessAccC[count+6]<-mydata$GuessPayoff.6.[i]
  PrevGuessAccC[count+7]<-mydata$GuessPayoff.7.[i]
  PrevGuessAccC[count+8]<-mydata$GuessPayoff.8.[i]
  PrevGuessAccC[count+9]<-mydata$GuessPayoff.9.[i]
  PrevGuessAccC[count+10]<-mydata$GuessPayoff.10.[i]
  PrevGuessAccC[count+11]<-mydata$GuessPayoff.11.[i]
  PrevGuessAccC[count+12]<-mydata$GuessPayoff.12.[i]
  PrevGuessAccC[count+13]<-mydata$GuessPayoff.13.[i]
  PrevGuessAccC[count+14]<-mydata$GuessPayoff.14.[i]
  PrevGuessAccC[count+15]<-mydata$GuessPayoff.15.[i]
  PrevGuessAccC[count+16]<-mydata$GuessPayoff.16.[i]
  jump<-16
  if(is.na(mydata$GuessPayoff.17.[i])==FALSE){PrevGuessAccC[count+17]<-mydata$GuessPayoff.17.[i]
  jump<-17}
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){PrevGuessAccC[count+18]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){PrevGuessAccC[count+19]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){PrevGuessAccC[count+20]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){PrevGuessAccC[count+21]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){PrevGuessAccC[count+22]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){PrevGuessAccC[count+23]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){PrevGuessAccC[count+24]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){PrevGuessAccC[count+25]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevGuessAccC<-c(PrevGuessAccC[1:1735])
tail(PrevGuessAccC, 38)
table(PrevGuessAccC)

#GuessAccC is a 1x1735 vector 
GuessAccC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  GuessAccC[count]<-mydata$GuessPayoff.1.[i]
  GuessAccC[count+1]<-mydata$GuessPayoff.2.[i]
  GuessAccC[count+2]<-mydata$GuessPayoff.3.[i]
  GuessAccC[count+3]<-mydata$GuessPayoff.4.[i]
  GuessAccC[count+4]<-mydata$GuessPayoff.5.[i]
  GuessAccC[count+5]<-mydata$GuessPayoff.6.[i]
  GuessAccC[count+6]<-mydata$GuessPayoff.7.[i]
  GuessAccC[count+7]<-mydata$GuessPayoff.8.[i]
  GuessAccC[count+8]<-mydata$GuessPayoff.9.[i]
  GuessAccC[count+9]<-mydata$GuessPayoff.10.[i]
  GuessAccC[count+10]<-mydata$GuessPayoff.11.[i]
  GuessAccC[count+11]<-mydata$GuessPayoff.12.[i]
  GuessAccC[count+12]<-mydata$GuessPayoff.13.[i]
  GuessAccC[count+13]<-mydata$GuessPayoff.14.[i]
  GuessAccC[count+14]<-mydata$GuessPayoff.15.[i]
  GuessAccC[count+15]<-mydata$GuessPayoff.16.[i]
  GuessAccC[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessAccC[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessAccC[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessAccC[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessAccC[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessAccC[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessAccC[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessAccC[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessAccC[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessAccC, 46)
table(GuessAccC)


#RoundC is a vector
RoundC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  RoundC[count]<-1
  RoundC[count+1]<-2
  RoundC[count+2]<-3
  RoundC[count+3]<-4
  RoundC[count+4]<-5
  RoundC[count+5]<-6
  RoundC[count+6]<-7
  RoundC[count+7]<-8
  RoundC[count+8]<-9
  RoundC[count+9]<-10
  RoundC[count+10]<-11
  RoundC[count+11]<-12
  RoundC[count+12]<-13
  RoundC[count+13]<-14
  RoundC[count+14]<-15
  RoundC[count+15]<-16
  RoundC[count+16]<-17
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){RoundC[count+17]<-18
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){RoundC[count+18]<-19
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){RoundC[count+19]<-20
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){RoundC[count+20]<-21
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){RoundC[count+21]<-22
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){RoundC[count+22]<-23
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){RoundC[count+23]<-24
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){RoundC[count+24]<-25
  jump<-25}
  count<-count+jump
}
}
tail(RoundC, 50)
table(RoundC)

#SexC is a 1x1735 vector 
SexC<-numeric(NumObsControl)
RiskC<-numeric(NumObsControl)
AgeC<-numeric(NumObsControl)
StudentTypeC<-numeric(NumObsControl)
StudyC<-numeric(NumObsControl)
DrivingC<-numeric(NumObsControl)
LearningC<-numeric(NumObsControl)
NormC<-numeric(NumObsControl)
count<-0
jump<-0
for(i in 1:obs){
  if(mydata$ExpType[i]==1){
  jump<-mydata$totper[i]-1
    for(j in 1:jump){
    SexC[count+j]<-mydata$sex[i]
    RiskC[count+j]<-mydata$RiskScore[i]
    AgeC[count+j]<-mydata$age[i]
    StudentTypeC[count+j]<-mydata$student[i]
    StudyC[count+j]<-mydata$study[i]
    DrivingC[count+j]<-mydata$Driving[i]
    LearningC[count+j]<-mydata$Learning[i]
    NormC[count+j]<-mydata$NormChoice[i]
    }
  count<-count+jump
  }
}
#turn the 2 values into 0s
for(i in 1:NumObsControl){
  if(SexC[i]==2){SexC[i]=0}
  if(StudentTypeC[i]==2){StudentTypeC[i]=0}
  if(DrivingC[i]==2){DrivingC[i]=0}
  if(LearningC[i]==2){LearningC[i]=0}
  }
head(RiskC,19*3+1)

#par(mfrow=c(1,1))

### using multinom
#Unused Variables: PrevGuessAccC
dataC<-data.frame(AutoFastSlowC, FastBeliefC, SlowBeliefC, AutoBeliefC, PrevEarnC,SexC, RiskC, AgeC, DrivingC,LearningC, PrevAccC)

#mlogitfitC<- multinom(AutoFastSlowC~DecTimeC+FastBeliefC+SlowBeliefC+ AutoBeliefC+ PrevAccC+GuessAccC+SexC+RiskC+ SexC+ AgeC+ DrivingC+ StudentTypeC+ LearningC, data=dataC)
mlogitfitC<- multinom(AutoFastSlowC~FastBeliefC+SlowBeliefC+ AutoBeliefC, data=dataC)
stargazer(mlogitfitC,dep.var.caption  = "Choice (relative to Slow)", title="Baseline", report=('vc*p'))


#mlogitfitC<- multinom(AutoFastSlowC~DecTimeC+FastBeliefC+SlowBeliefC+ AutoBeliefC+ PrevAccC+GuessAccC+SexC+RiskC+ SexC+ AgeC+ DrivingC+ StudentTypeC+ LearningC, data=dataC)
mlogitfitC<- multinom(AutoFastSlowC~FastBeliefC+SlowBeliefC+ AutoBeliefC +RiskC+SexC+ AgeC+ PrevEarnC+ LearningC+DrivingC, data=dataC)
stargazer(mlogitfitC,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))


mlogitfitC<- multinom(AutoFastSlowC~FastBeliefC+SlowBeliefC+ AutoBeliefC +RiskC+SexC+ PrevEarnC+ LearningC+DrivingC, data=dataC)
stargazer(mlogitfitC,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))



mlogitfitC<- multinom(AutoFastSlowC~FastBeliefC+SlowBeliefC+ AutoBeliefC +RiskC+SexC+ PrevEarnC+PrevAccC+ LearningC+DrivingC, data=dataC)
stargazer(mlogitfitC,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))





#How do people make decisions in the Fine environment?

#AutoFastSlowF is a 1x1735 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  AutoFastSlowF[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowF[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowF[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowF[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowF[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowF[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowF[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowF[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowF[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowF[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowF[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowF[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowF[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowF[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowF[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowF[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowF[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowF[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowF[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowF[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowF[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowF[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowF[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowF[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowF[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowF, 46)
table(AutoFastSlowF)
#Change numbers to names (optional)
for(i in 1:NumObsFine){ifelse(AutoFastSlowF[i]==1, AutoFastSlowF[i]<-"Fast", ifelse(AutoFastSlowF[i]==2, AutoFastSlowF[i]<-0, AutoFastSlowF[i]<-'Auto'))}


#DecTimeF is a 1x1735 vector 
DecTimeF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  DecTimeF[count]<-mydata$DecTime.1.[i]
  DecTimeF[count+1]<-mydata$DecTime.2.[i]
  DecTimeF[count+2]<-mydata$DecTime.3.[i]
  DecTimeF[count+3]<-mydata$DecTime.4.[i]
  DecTimeF[count+4]<-mydata$DecTime.5.[i]
  DecTimeF[count+5]<-mydata$DecTime.6.[i]
  DecTimeF[count+6]<-mydata$DecTime.7.[i]
  DecTimeF[count+7]<-mydata$DecTime.8.[i]
  DecTimeF[count+8]<-mydata$DecTime.9.[i]
  DecTimeF[count+9]<-mydata$DecTime.10.[i]
  DecTimeF[count+10]<-mydata$DecTime.11.[i]
  DecTimeF[count+11]<-mydata$DecTime.12.[i]
  DecTimeF[count+12]<-mydata$DecTime.13.[i]
  DecTimeF[count+13]<-mydata$DecTime.14.[i]
  DecTimeF[count+14]<-mydata$DecTime.15.[i]
  DecTimeF[count+15]<-mydata$DecTime.16.[i]
  DecTimeF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#DecTimeF <- DecTimeF[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(DecTimeF, 46)
table(DecTimeF)


#FastBeliefF is a 1x1735 vector 
FastBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  FastBeliefF[count]<-mydata$GuessFast.1.[i]
  FastBeliefF[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefF[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefF[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefF[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefF[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefF[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefF[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefF[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefF[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefF[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefF[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefF[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefF[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefF[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefF[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefF[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefF[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefF[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefF[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefF[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefF[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefF[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefF[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefF[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(FastBeliefF, 46)
table(FastBeliefF)

#SlowBeliefF is a 1x1735 vector 
SlowBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  SlowBeliefF[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefF[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefF[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefF[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefF[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefF[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefF[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefF[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefF[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefF[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefF[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefF[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefF[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefF[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefF[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefF[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefF[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefF[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefF[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefF[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefF[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefF[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefF[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefF[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefF[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(SlowBeliefF, 46)
table(SlowBeliefF)

#AutoBeliefF is a 1x1735 vector 
AutoBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  AutoBeliefF[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefF[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefF[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefF[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefF[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefF[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefF[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefF[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefF[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefF[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefF[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefF[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefF[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefF[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefF[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefF[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefF[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefF[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefF[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefF[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefF[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefF[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefF[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefF[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefF[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(AutoBeliefF, 46)
table(AutoBeliefF)


#PrevEarnF is a  vector 
PrevEarnF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  PrevEarnF[count]<-0
  PrevEarnF[count+1]<-mydata$ChoicePayoff.1.[i]
  PrevEarnF[count+2]<-mydata$ChoicePayoff.2.[i]
  PrevEarnF[count+3]<-mydata$ChoicePayoff.3.[i]
  PrevEarnF[count+4]<-mydata$ChoicePayoff.4.[i]
  PrevEarnF[count+5]<-mydata$ChoicePayoff.5.[i]
  PrevEarnF[count+6]<-mydata$ChoicePayoff.6.[i]
  PrevEarnF[count+7]<-mydata$ChoicePayoff.7.[i]
  PrevEarnF[count+8]<-mydata$ChoicePayoff.8.[i]
  PrevEarnF[count+9]<-mydata$ChoicePayoff.9.[i]
  PrevEarnF[count+10]<-mydata$ChoicePayoff.10.[i]
  PrevEarnF[count+11]<-mydata$ChoicePayoff.11.[i]
  PrevEarnF[count+12]<-mydata$ChoicePayoff.12.[i]
  PrevEarnF[count+13]<-mydata$ChoicePayoff.13.[i]
  PrevEarnF[count+14]<-mydata$ChoicePayoff.14.[i]
  PrevEarnF[count+15]<-mydata$ChoicePayoff.15.[i]
  PrevEarnF[count+16]<-mydata$ChoicePayoff.16.[i]
  jump<-16
  if(is.na(mydata$ChoicePayoff.17.[i])==FALSE){PrevEarnF[count+17]<-mydata$ChoicePayoff.17.[i]
  jump<-17}
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PrevEarnF[count+18]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PrevEarnF[count+19]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PrevEarnF[count+20]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PrevEarnF[count+21]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PrevEarnF[count+22]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PrevEarnF[count+23]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PrevEarnF[count+24]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PrevEarnF[count+25]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevEarnF<-c(PrevEarnF[1:1703])
tail(PrevEarnF, 38)
table(PrevEarnF)

#PrevAccF is a 1x1735 vector 
PrevAccF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  PrevAccF[count]<-0
  PrevAccF[count+1]<-mydata$AccidentHistory.1.[i]
  PrevAccF[count+2]<-mydata$AccidentHistory.2.[i]
  PrevAccF[count+3]<-mydata$AccidentHistory.3.[i]
  PrevAccF[count+4]<-mydata$AccidentHistory.4.[i]
  PrevAccF[count+5]<-mydata$AccidentHistory.5.[i]
  PrevAccF[count+6]<-mydata$AccidentHistory.6.[i]
  PrevAccF[count+7]<-mydata$AccidentHistory.7.[i]
  PrevAccF[count+8]<-mydata$AccidentHistory.8.[i]
  PrevAccF[count+9]<-mydata$AccidentHistory.9.[i]
  PrevAccF[count+10]<-mydata$AccidentHistory.10.[i]
  PrevAccF[count+11]<-mydata$AccidentHistory.11.[i]
  PrevAccF[count+12]<-mydata$AccidentHistory.12.[i]
  PrevAccF[count+13]<-mydata$AccidentHistory.13.[i]
  PrevAccF[count+14]<-mydata$AccidentHistory.14.[i]
  PrevAccF[count+15]<-mydata$AccidentHistory.15.[i]
  PrevAccF[count+16]<-mydata$AccidentHistory.16.[i]
  jump<-16
  if(is.na(mydata$AccidentHistory.17.[i])==FALSE){PrevAccF[count+17]<-mydata$AccidentHistory.17.[i]
  jump<-17}
  if(is.na(mydata$AccidentHistory.18.[i])==FALSE){PrevAccF[count+18]<-mydata$AccidentHistory.18.[i]
  jump<-18}
  if(is.na(mydata$AccidentHistory.19.[i])==FALSE){PrevAccF[count+19]<-mydata$AccidentHistory.19.[i]
  jump<-19}
  if(is.na(mydata$AccidentHistory.20.[i])==FALSE){PrevAccF[count+20]<-mydata$AccidentHistory.20.[i]
  jump<-20}
  if(is.na(mydata$AccidentHistory.21.[i])==FALSE){PrevAccF[count+21]<-mydata$AccidentHistory.21.[i]
  jump<-21}
  if(is.na(mydata$AccidentHistory.22.[i])==FALSE){PrevAccF[count+22]<-mydata$AccidentHistory.22.[i]
  jump<-22}
  if(is.na(mydata$AccidentHistory.23.[i])==FALSE){PrevAccF[count+23]<-mydata$AccidentHistory.23.[i]
  jump<-23}
  if(is.na(mydata$AccidentHistory.24.[i])==FALSE){PrevAccF[count+24]<-mydata$AccidentHistory.24.[i]
  jump<-24}
  if(is.na(mydata$AccidentHistory.25.[i])==FALSE){PrevAccF[count+25]<-mydata$AccidentHistory.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevAccF<-c(PrevAccF[1:1703])
tail(PrevAccF, 38)
table(PrevAccF)

#PrevGuessAccF is a 1x1735 vector 
PrevGuessAccF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  PrevGuessAccF[count]<-0
  PrevGuessAccF[count+1]<-mydata$GuessPayoff.1.[i]
  PrevGuessAccF[count+2]<-mydata$GuessPayoff.2.[i]
  PrevGuessAccF[count+3]<-mydata$GuessPayoff.3.[i]
  PrevGuessAccF[count+4]<-mydata$GuessPayoff.4.[i]
  PrevGuessAccF[count+5]<-mydata$GuessPayoff.5.[i]
  PrevGuessAccF[count+6]<-mydata$GuessPayoff.6.[i]
  PrevGuessAccF[count+7]<-mydata$GuessPayoff.7.[i]
  PrevGuessAccF[count+8]<-mydata$GuessPayoff.8.[i]
  PrevGuessAccF[count+9]<-mydata$GuessPayoff.9.[i]
  PrevGuessAccF[count+10]<-mydata$GuessPayoff.10.[i]
  PrevGuessAccF[count+11]<-mydata$GuessPayoff.11.[i]
  PrevGuessAccF[count+12]<-mydata$GuessPayoff.12.[i]
  PrevGuessAccF[count+13]<-mydata$GuessPayoff.13.[i]
  PrevGuessAccF[count+14]<-mydata$GuessPayoff.14.[i]
  PrevGuessAccF[count+15]<-mydata$GuessPayoff.15.[i]
  PrevGuessAccF[count+16]<-mydata$GuessPayoff.16.[i]
  jump<-16
  if(is.na(mydata$GuessPayoff.17.[i])==FALSE){PrevGuessAccF[count+17]<-mydata$GuessPayoff.17.[i]
  jump<-17}
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){PrevGuessAccF[count+18]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){PrevGuessAccF[count+19]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){PrevGuessAccF[count+20]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){PrevGuessAccF[count+21]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){PrevGuessAccF[count+22]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){PrevGuessAccF[count+23]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){PrevGuessAccF[count+24]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){PrevGuessAccF[count+25]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevGuessAccF<-c(PrevGuessAccF[1:1703])
tail(PrevGuessAccF, 38)
table(PrevGuessAccF)

#GuessAccF is a 1x1735 vector 
GuessAccF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  GuessAccF[count]<-mydata$GuessPayoff.1.[i]
  GuessAccF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessAccF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessAccF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessAccF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessAccF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessAccF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessAccF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessAccF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessAccF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessAccF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessAccF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessAccF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessAccF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessAccF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessAccF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessAccF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessAccF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessAccF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessAccF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessAccF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessAccF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessAccF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessAccF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessAccF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessAccF, 46)
table(GuessAccF)

#SexF is a 1x1703 vector 
SexF<-numeric(NumObsFine)
RiskF<-numeric(NumObsFine)
AgeF<-numeric(NumObsFine)
StudentTypeF<-numeric(NumObsFine)
StudyF<-numeric(NumObsFine)
DrivingF<-numeric(NumObsFine)
LearningF<-numeric(NumObsFine)
NormF<-numeric(NumObsFine)
count<-0
jump<-0
for(i in 1:obs){
  if(mydata$ExpType[i]==2){
    jump<-mydata$totper[i]-1
    for(j in 1:jump){
      SexF[count+j]<-mydata$sex[i]
      RiskF[count+j]<-mydata$RiskScore[i]
      AgeF[count+j]<-mydata$age[i]
      StudentTypeF[count+j]<-mydata$student[i]
      StudyF[count+j]<-mydata$study[i]
      DrivingF[count+j]<-mydata$Driving[i]
      LearningF[count+j]<-mydata$Learning[i]
      NormF[count+j]<-mydata$NormChoice[i]
    }
    count<-count+jump
  }
}
#turn the 2 values into 0s
for(i in 1:NumObsFine){
  if(SexF[i]==2){SexF[i]=0}
  if(StudentTypeF[i]==2){StudentTypeF[i]=0}
  if(DrivingF[i]==2){DrivingF[i]=0}
  if(LearningF[i]==2){LearningF[i]=0}
}
tail(RiskF,19*3+1)

#par(mfrow=c(1,1))

### using multinom
#Unused Variables: PrevGuessAccF
dataF<-data.frame(AutoFastSlowF, FastBeliefF, SlowBeliefF, AutoBeliefF, PrevEarnF,PrevAccF, RiskF, SexF, AgeF, DrivingF, LearningF)
mlogitfitF<- multinom(AutoFastSlowF~FastBeliefF+SlowBeliefF+ AutoBeliefF+ RiskF+SexF+PrevEarnF+PrevAccF+ LearningF +DrivingF, data=dataF)
summary(mlogitfitF)
z <- summary(mlogitfitF)$coefficients/summary(mlogitfitF)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p

stargazer(mlogitfitF,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))




#How do people make decisions in the Association environment?

#AutoFastSlowA is a 1x1735 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  AutoFastSlowA[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowA[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowA[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowA[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowA[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowA[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowA[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowA[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowA[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowA[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowA[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowA[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowA[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowA[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowA[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowA[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowA[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowA[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowA[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowA[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowA[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowA[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowA[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowA[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowA[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowA, 46)
table(AutoFastSlowA)
#Change numbers to names (optional)
for(i in 1:NumObsAssoc){ifelse(AutoFastSlowA[i]==1, AutoFastSlowA[i]<-"Fast", ifelse(AutoFastSlowA[i]==2, AutoFastSlowA[i]<-0, AutoFastSlowA[i]<-'Auto'))}


#DecTimeA is a 1x1735 vector 
DecTimeA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  DecTimeA[count]<-mydata$DecTime.1.[i]
  DecTimeA[count+1]<-mydata$DecTime.2.[i]
  DecTimeA[count+2]<-mydata$DecTime.3.[i]
  DecTimeA[count+3]<-mydata$DecTime.4.[i]
  DecTimeA[count+4]<-mydata$DecTime.5.[i]
  DecTimeA[count+5]<-mydata$DecTime.6.[i]
  DecTimeA[count+6]<-mydata$DecTime.7.[i]
  DecTimeA[count+7]<-mydata$DecTime.8.[i]
  DecTimeA[count+8]<-mydata$DecTime.9.[i]
  DecTimeA[count+9]<-mydata$DecTime.10.[i]
  DecTimeA[count+10]<-mydata$DecTime.11.[i]
  DecTimeA[count+11]<-mydata$DecTime.12.[i]
  DecTimeA[count+12]<-mydata$DecTime.13.[i]
  DecTimeA[count+13]<-mydata$DecTime.14.[i]
  DecTimeA[count+14]<-mydata$DecTime.15.[i]
  DecTimeA[count+15]<-mydata$DecTime.16.[i]
  DecTimeA[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeA[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeA[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeA[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeA[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeA[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeA[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeA[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeA[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#DecTimeA <- DecTimeA[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(DecTimeA, 46)
table(DecTimeA)


#FastBeliefA is a 1x1735 vector 
FastBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  FastBeliefA[count]<-mydata$GuessFast.1.[i]
  FastBeliefA[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefA[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefA[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefA[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefA[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefA[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefA[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefA[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefA[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefA[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefA[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefA[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefA[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefA[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefA[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefA[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefA[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefA[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefA[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefA[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefA[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefA[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefA[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefA[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(FastBeliefA, 46)
table(FastBeliefA)

#SlowBeliefA is a 1x1735 vector 
SlowBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  SlowBeliefA[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefA[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefA[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefA[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefA[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefA[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefA[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefA[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefA[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefA[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefA[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefA[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefA[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefA[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefA[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefA[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefA[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefA[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefA[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefA[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefA[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefA[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefA[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefA[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefA[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(SlowBeliefA, 46)
table(SlowBeliefA)

#AutoBeliefA is a 1x1735 vector 
AutoBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  AutoBeliefA[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefA[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefA[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefA[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefA[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefA[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefA[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefA[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefA[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefA[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefA[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefA[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefA[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefA[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefA[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefA[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefA[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefA[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefA[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefA[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefA[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefA[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefA[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefA[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefA[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(AutoBeliefA, 46)
table(AutoBeliefA)


#EarnA is a 1x1735 vector 
EarnA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  EarnA[count]<-mydata$ChoicePayoff.1.[i]
  EarnA[count+1]<-mydata$ChoicePayoff.2.[i]
  EarnA[count+2]<-mydata$ChoicePayoff.3.[i]
  EarnA[count+3]<-mydata$ChoicePayoff.4.[i]
  EarnA[count+4]<-mydata$ChoicePayoff.5.[i]
  EarnA[count+5]<-mydata$ChoicePayoff.6.[i]
  EarnA[count+6]<-mydata$ChoicePayoff.7.[i]
  EarnA[count+7]<-mydata$ChoicePayoff.8.[i]
  EarnA[count+8]<-mydata$ChoicePayoff.9.[i]
  EarnA[count+9]<-mydata$ChoicePayoff.10.[i]
  EarnA[count+10]<-mydata$ChoicePayoff.11.[i]
  EarnA[count+11]<-mydata$ChoicePayoff.12.[i]
  EarnA[count+12]<-mydata$ChoicePayoff.13.[i]
  EarnA[count+13]<-mydata$ChoicePayoff.14.[i]
  EarnA[count+14]<-mydata$ChoicePayoff.15.[i]
  EarnA[count+15]<-mydata$ChoicePayoff.16.[i]
  EarnA[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){EarnA[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){EarnA[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){EarnA[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){EarnA[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){EarnA[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){EarnA[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){EarnA[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){EarnA[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(EarnA, 46)
table(EarnA,SexIA)


#EarnAny is a 1xEarnANy vector 
EarnAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 | mydata$ExpType[i]==3| mydata$ExpType[i]==4){
  EarnAny[count]<-mydata$ChoicePayoff.1.[i]
  EarnAny[count+1]<-mydata$ChoicePayoff.2.[i]
  EarnAny[count+2]<-mydata$ChoicePayoff.3.[i]
  EarnAny[count+3]<-mydata$ChoicePayoff.4.[i]
  EarnAny[count+4]<-mydata$ChoicePayoff.5.[i]
  EarnAny[count+5]<-mydata$ChoicePayoff.6.[i]
  EarnAny[count+6]<-mydata$ChoicePayoff.7.[i]
  EarnAny[count+7]<-mydata$ChoicePayoff.8.[i]
  EarnAny[count+8]<-mydata$ChoicePayoff.9.[i]
  EarnAny[count+9]<-mydata$ChoicePayoff.10.[i]
  EarnAny[count+10]<-mydata$ChoicePayoff.11.[i]
  EarnAny[count+11]<-mydata$ChoicePayoff.12.[i]
  EarnAny[count+12]<-mydata$ChoicePayoff.13.[i]
  EarnAny[count+13]<-mydata$ChoicePayoff.14.[i]
  EarnAny[count+14]<-mydata$ChoicePayoff.15.[i]
  EarnAny[count+15]<-mydata$ChoicePayoff.16.[i]
  EarnAny[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){EarnAny[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){EarnAny[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){EarnAny[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){EarnAny[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){EarnAny[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){EarnAny[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){EarnAny[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){EarnAny[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(EarnAny, 46)



#EarnC is a 1x1735 vector 
EarnC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  EarnC[count]<-mydata$ChoicePayoff.1.[i]
  EarnC[count+1]<-mydata$ChoicePayoff.2.[i]
  EarnC[count+2]<-mydata$ChoicePayoff.3.[i]
  EarnC[count+3]<-mydata$ChoicePayoff.4.[i]
  EarnC[count+4]<-mydata$ChoicePayoff.5.[i]
  EarnC[count+5]<-mydata$ChoicePayoff.6.[i]
  EarnC[count+6]<-mydata$ChoicePayoff.7.[i]
  EarnC[count+7]<-mydata$ChoicePayoff.8.[i]
  EarnC[count+8]<-mydata$ChoicePayoff.9.[i]
  EarnC[count+9]<-mydata$ChoicePayoff.10.[i]
  EarnC[count+10]<-mydata$ChoicePayoff.11.[i]
  EarnC[count+11]<-mydata$ChoicePayoff.12.[i]
  EarnC[count+12]<-mydata$ChoicePayoff.13.[i]
  EarnC[count+13]<-mydata$ChoicePayoff.14.[i]
  EarnC[count+14]<-mydata$ChoicePayoff.15.[i]
  EarnC[count+15]<-mydata$ChoicePayoff.16.[i]
  EarnC[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){EarnC[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){EarnC[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){EarnC[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){EarnC[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){EarnC[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){EarnC[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){EarnC[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){EarnC[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(EarnC, 46)


#EarnP is a 1x1735 vector 
EarnP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  EarnP[count]<-mydata$ChoicePayoff.1.[i]
  EarnP[count+1]<-mydata$ChoicePayoff.2.[i]
  EarnP[count+2]<-mydata$ChoicePayoff.3.[i]
  EarnP[count+3]<-mydata$ChoicePayoff.4.[i]
  EarnP[count+4]<-mydata$ChoicePayoff.5.[i]
  EarnP[count+5]<-mydata$ChoicePayoff.6.[i]
  EarnP[count+6]<-mydata$ChoicePayoff.7.[i]
  EarnP[count+7]<-mydata$ChoicePayoff.8.[i]
  EarnP[count+8]<-mydata$ChoicePayoff.9.[i]
  EarnP[count+9]<-mydata$ChoicePayoff.10.[i]
  EarnP[count+10]<-mydata$ChoicePayoff.11.[i]
  EarnP[count+11]<-mydata$ChoicePayoff.12.[i]
  EarnP[count+12]<-mydata$ChoicePayoff.13.[i]
  EarnP[count+13]<-mydata$ChoicePayoff.14.[i]
  EarnP[count+14]<-mydata$ChoicePayoff.15.[i]
  EarnP[count+15]<-mydata$ChoicePayoff.16.[i]
  EarnP[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){EarnP[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){EarnP[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){EarnP[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){EarnP[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){EarnP[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){EarnP[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){EarnP[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){EarnP[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(EarnP, 46)


#EarnF is a 1x1735 vector 
EarnF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  EarnF[count]<-mydata$ChoicePayoff.1.[i]
  EarnF[count+1]<-mydata$ChoicePayoff.2.[i]
  EarnF[count+2]<-mydata$ChoicePayoff.3.[i]
  EarnF[count+3]<-mydata$ChoicePayoff.4.[i]
  EarnF[count+4]<-mydata$ChoicePayoff.5.[i]
  EarnF[count+5]<-mydata$ChoicePayoff.6.[i]
  EarnF[count+6]<-mydata$ChoicePayoff.7.[i]
  EarnF[count+7]<-mydata$ChoicePayoff.8.[i]
  EarnF[count+8]<-mydata$ChoicePayoff.9.[i]
  EarnF[count+9]<-mydata$ChoicePayoff.10.[i]
  EarnF[count+10]<-mydata$ChoicePayoff.11.[i]
  EarnF[count+11]<-mydata$ChoicePayoff.12.[i]
  EarnF[count+12]<-mydata$ChoicePayoff.13.[i]
  EarnF[count+13]<-mydata$ChoicePayoff.14.[i]
  EarnF[count+14]<-mydata$ChoicePayoff.15.[i]
  EarnF[count+15]<-mydata$ChoicePayoff.16.[i]
  EarnF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){EarnF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){EarnF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){EarnF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){EarnF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){EarnF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){EarnF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){EarnF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){EarnF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(EarnF, 46)


NumObsAny = NumObsAssoc+NumObsPun+NumObsFine

#PREV FAST VARIABLES

#PrevFastAny is a 1xAny vector 
PrevFastAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1 | PunDummy[i]==1 | FineDummy[i]==1 ){
  if(PrevChoice[i]==0){PrevFastAny[count]<-0}
  if(PrevChoice[i]==1){PrevFastAny[count]<-0}
  if(PrevChoice[i]==2){PrevFastAny[count]<-0}
  if(PrevChoice[i]==3){PrevFastAny[count]<-1}
  count<-count+1
}
}
table(PrevFastAny)

#PrevFastA is a 1xASSOC vector 
PrevFastA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1){
  if(PrevChoice[i]==0){PrevFastA[count]<-0}
  if(PrevChoice[i]==1){PrevFastA[count]<-0}
  if(PrevChoice[i]==2){PrevFastA[count]<-0}
  if(PrevChoice[i]==3){PrevFastA[count]<-1}
  count<-count+1
}
}
table(PrevFastA)

#PrevFastC is a 1xASSOC vector 
PrevFastC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==0 & PunDummy[i]==0 & FineDummy[i]==0 ){
  if(PrevChoice[i]==0){PrevFastC[count]<-0}
  if(PrevChoice[i]==1){PrevFastC[count]<-0}
  if(PrevChoice[i]==2){PrevFastC[count]<-0}
  if(PrevChoice[i]==3){PrevFastC[count]<-1}
  count<-count+1
}
}
table(PrevFastC)

#PrevFastP is a 1xASSOC vector 
PrevFastP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(PunDummy[i]==1){
  if(PrevChoice[i]==0){PrevFastP[count]<-0}
  if(PrevChoice[i]==1){PrevFastP[count]<-0}
  if(PrevChoice[i]==2){PrevFastP[count]<-0}
  if(PrevChoice[i]==3){PrevFastP[count]<-1}
  count<-count+1
}
}
table(PrevFastP)


#PrevFastF is a 1xASSOC vector 
PrevFastF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(FineDummy[i]==1){
  if(PrevChoice[i]==0){PrevFastF[count]<-0}
  if(PrevChoice[i]==1){PrevFastF[count]<-0}
  if(PrevChoice[i]==2){PrevFastF[count]<-0}
  if(PrevChoice[i]==3){PrevFastF[count]<-1}
  count<-count+1
}
}
table(PrevFastF)




#PREV Slow VARIABLES

#PrevSlowAny is a 1xAny vector 
PrevSlowAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1 | PunDummy[i]==1 | FineDummy[i]==1 ){
  if(PrevChoice[i]==0){PrevSlowAny[count]<-0}
  if(PrevChoice[i]==1){PrevSlowAny[count]<-0}
  if(PrevChoice[i]==2){PrevSlowAny[count]<-1}
  if(PrevChoice[i]==3){PrevSlowAny[count]<-0}
  count<-count+1
}
}
table(PrevSlowAny)

#PrevSlowA is a 1xASSOC vector 
PrevSlowA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1){
  if(PrevChoice[i]==0){PrevSlowA[count]<-0}
  if(PrevChoice[i]==1){PrevSlowA[count]<-0}
  if(PrevChoice[i]==2){PrevSlowA[count]<-1}
  if(PrevChoice[i]==3){PrevSlowA[count]<-0}
  count<-count+1
}
}
table(PrevSlowA)

#PrevSlowC is a 1xASSOC vector 
PrevSlowC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==0 & PunDummy[i]==0 & FineDummy[i]==0 ){
  if(PrevChoice[i]==0){PrevSlowC[count]<-0}
  if(PrevChoice[i]==1){PrevSlowC[count]<-0}
  if(PrevChoice[i]==2){PrevSlowC[count]<-1}
  if(PrevChoice[i]==3){PrevSlowC[count]<-0}
  count<-count+1
}
}
table(PrevSlowC)

#PrevSlowP is a 1xASSOC vector 
PrevSlowP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(PunDummy[i]==1){
  if(PrevChoice[i]==0){PrevSlowP[count]<-0}
  if(PrevChoice[i]==1){PrevSlowP[count]<-0}
  if(PrevChoice[i]==2){PrevSlowP[count]<-1}
  if(PrevChoice[i]==3){PrevSlowP[count]<-0}
  count<-count+1
}
}
table(PrevSlowP)


#PrevSlowF is a 1xASSOC vector 
PrevSlowF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(FineDummy[i]==1){
  if(PrevChoice[i]==0){PrevSlowF[count]<-0}
  if(PrevChoice[i]==1){PrevSlowF[count]<-0}
  if(PrevChoice[i]==2){PrevSlowF[count]<-1}
  if(PrevChoice[i]==3){PrevSlowF[count]<-0}
  count<-count+1
}
}
table(PrevSlowF)




#PREV Auto VARIABLES


#PrevAutoAny is a 1xAny vector 
PrevAutoAny<-numeric(NumObsAny)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1 | PunDummy[i]==1 | FineDummy[i]==1 ){
  if(PrevChoice[i]==0){PrevAutoAny[count]<-0}
  if(PrevChoice[i]==1){PrevAutoAny[count]<-1}
  if(PrevChoice[i]==2){PrevAutoAny[count]<-0}
  if(PrevChoice[i]==3){PrevAutoAny[count]<-0}
  count<-count+1
}
}
table(PrevAutoAny)

#PrevAutoA is a 1xASSOC vector 
PrevAutoA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==1){
  if(PrevChoice[i]==0){PrevAutoA[count]<-0}
  if(PrevChoice[i]==1){PrevAutoA[count]<-1}
  if(PrevChoice[i]==2){PrevAutoA[count]<-0}
  if(PrevChoice[i]==3){PrevAutoA[count]<-0}
  count<-count+1
}
}
table(PrevAutoA)

#PrevAutoC is a 1xASSOC vector 
PrevAutoC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(AssocDummy[i]==0 & PunDummy[i]==0 & FineDummy[i]==0 ){
  if(PrevChoice[i]==0){PrevAutoC[count]<-0}
  if(PrevChoice[i]==1){PrevAutoC[count]<-1}
  if(PrevChoice[i]==2){PrevAutoC[count]<-0}
  if(PrevChoice[i]==3){PrevAutoC[count]<-0}
  count<-count+1
}
}
table(PrevAutoC)

#PrevAutoP is a 1xASSOC vector 
PrevAutoP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(PunDummy[i]==1){
  if(PrevChoice[i]==0){PrevAutoP[count]<-0}
  if(PrevChoice[i]==1){PrevAutoP[count]<-1}
  if(PrevChoice[i]==2){PrevAutoP[count]<-0}
  if(PrevChoice[i]==3){PrevAutoP[count]<-0}
  count<-count+1
}
}
table(PrevAutoP)


#PrevAutoF is a 1xASSOC vector 
PrevAutoF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:NumObsTotal){if(FineDummy[i]==1){
  if(PrevChoice[i]==0){PrevAutoF[count]<-0}
  if(PrevChoice[i]==1){PrevAutoF[count]<-1}
  if(PrevChoice[i]==2){PrevAutoF[count]<-0}
  if(PrevChoice[i]==3){PrevAutoF[count]<-0}
  count<-count+1
}
}
table(PrevAutoF)





SessCountA<-numeric(NumObsAssoc)
count<-1
for(i in 1:NumObsTotal){if(AssocDummy[i]==1){
  SessCountA[count]=SessCount[i]
  count<-count+1
}
}
table(SessCountA)


SessCountC<-numeric(NumObsControl)
count<-1
for(i in 1:NumObsTotal){if(AssocDummy[i]==0 & PunDummy[i]==0 & FineDummy[i]==0 ){
  SessCountC[count]=SessCount[i]
  count<-count+1
}
}
table(SessCountC)


SessCountF<-numeric(NumObsFine)
count<-1
for(i in 1:NumObsTotal){if(FineDummy[i]==1){
  SessCountF[count]=SessCount[i]
  count<-count+1
}
}
table(SessCountF)


SessCountP<-numeric(NumObsPun)
count<-1
for(i in 1:NumObsTotal){if(PunDummy[i]==1){
  SessCountP[count]=SessCount[i]
  count<-count+1
}
}
table(SessCountP)


SessCountAny<-numeric(NumObsAny)
count<-1
for(i in 1:NumObsTotal){if(AssocDummy[i]==1 | FineDummy[i]==1 | PunDummy[i]==1){
  SessCountAny[count]=SessCount[i]
  count<-count+1
}
}
table(SessCountAny)



#PropFemale is a 1x6749 vector
PropFemale<-numeric(NumObsTotal)
for(i in 1:NumObsTotal){
  if(SessNum[i]==1){PropFemale[i]=3/8}
  if(SessNum[i]==2){PropFemale[i]=4/10}
  if(SessNum[i]==3){PropFemale[i]=5/10}
  if(SessNum[i]==4){PropFemale[i]=5/9}
  if(SessNum[i]==5){PropFemale[i]=3/9}
  if(SessNum[i]==6){PropFemale[i]=5/8}
  if(SessNum[i]==7){PropFemale[i]=8/12}
  if(SessNum[i]==8){PropFemale[i]=8/12}
  if(SessNum[i]==9){PropFemale[i]=3/8}
  if(SessNum[i]==10){PropFemale[i]=2/8}
  if(SessNum[i]==11){PropFemale[i]=6/12}
  if(SessNum[i]==12){PropFemale[i]=7/9}
  if(SessNum[i]==13){PropFemale[i]=3/9}
  if(SessNum[i]==14){PropFemale[i]=6/11}
  if(SessNum[i]==15){PropFemale[i]=2/10}
  if(SessNum[i]==16){PropFemale[i]=5/10}
  if(SessNum[i]==17){PropFemale[i]=4/9}
  if(SessNum[i]==18){PropFemale[i]=7/10}
  if(SessNum[i]==19){PropFemale[i]=2/8}
  if(SessNum[i]==20){PropFemale[i]=8/12}
  if(SessNum[i]==21){PropFemale[i]=9/12}
  if(SessNum[i]==22){PropFemale[i]=5/12}
  if(SessNum[i]==23){PropFemale[i]=4/9}
  if(SessNum[i]==24){PropFemale[i]=9/12}
  if(SessNum[i]==25){PropFemale[i]=7/12}
  if(SessNum[i]==26){PropFemale[i]=6/11}
  if(SessNum[i]==27){PropFemale[i]=7/12}
  if(SessNum[i]==28){PropFemale[i]=4/11}
  if(SessNum[i]==29){PropFemale[i]=6/11}
  if(SessNum[i]==30){PropFemale[i]=4/9}
  if(SessNum[i]==31){PropFemale[i]=6/11}
  if(SessNum[i]==32){PropFemale[i]=8/10}
}

  
### using multinom
dataA<-data.frame(EarnA,SexIA,RiskA,PrevEarnA,RoundNumLateA,PrevAccA, PrevFastA, PrevSlowA, PrevAutoA, SessNumA, SessCountA, PropFemaleA)
#Export to stata
library(foreign)
write.dta(dataA, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREVA.dta")
#C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")


### using multinom
dataC<-data.frame(EarnC,SexIC,RiskC,PrevEarnC,RoundNumLateC,PrevAccC, PrevFastC, PrevSlowC, PrevAutoC, SessNumC, SessCountC, PropFemaleC)
#Export to stata
library(foreign)
write.dta(dataC, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREVC.dta")
#C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")


### using multinom
dataP<-data.frame(EarnP,SexIP,RiskP,PrevEarnP,RoundNumLateP,PrevAccP, PrevFastP, PrevSlowP, PrevAutoP, SessNumP, SessCountP, PropFemaleP)
#Export to stata
library(foreign)
write.dta(dataP, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREVP.dta")
#C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")


### using multinom
dataF<-data.frame(EarnF,SexIF,RiskF,PrevEarnF,RoundNumLateF,PrevAccF, PrevFastF, PrevSlowF, PrevAutoF, SessNumF, SessCountF, PropFemaleF)
#Export to stata
library(foreign)
write.dta(dataF, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREVF.dta")
#C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")



### using multinom
dataAny<-data.frame(EarnAny,SexIAny,RiskAny,RoundNumLateAny, PrevFastAny, PrevSlowAny, PrevAutoAny, SessNumAny, SessCountAny, PropFemaleAny)
#Export to stata
library(foreign)
write.dta(dataAny, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREVAny.dta")
#C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")




#PrevEarnA is a  vector 
PrevEarnA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  PrevEarnA[count]<-0
  PrevEarnA[count+1]<-mydata$ChoicePayoff.1.[i]
  PrevEarnA[count+2]<-mydata$ChoicePayoff.2.[i]
  PrevEarnA[count+3]<-mydata$ChoicePayoff.3.[i]
  PrevEarnA[count+4]<-mydata$ChoicePayoff.4.[i]
  PrevEarnA[count+5]<-mydata$ChoicePayoff.5.[i]
  PrevEarnA[count+6]<-mydata$ChoicePayoff.6.[i]
  PrevEarnA[count+7]<-mydata$ChoicePayoff.7.[i]
  PrevEarnA[count+8]<-mydata$ChoicePayoff.8.[i]
  PrevEarnA[count+9]<-mydata$ChoicePayoff.9.[i]
  PrevEarnA[count+10]<-mydata$ChoicePayoff.10.[i]
  PrevEarnA[count+11]<-mydata$ChoicePayoff.11.[i]
  PrevEarnA[count+12]<-mydata$ChoicePayoff.12.[i]
  PrevEarnA[count+13]<-mydata$ChoicePayoff.13.[i]
  PrevEarnA[count+14]<-mydata$ChoicePayoff.14.[i]
  PrevEarnA[count+15]<-mydata$ChoicePayoff.15.[i]
  PrevEarnA[count+16]<-mydata$ChoicePayoff.16.[i]
  jump<-16
  if(is.na(mydata$ChoicePayoff.17.[i])==FALSE){PrevEarnA[count+17]<-mydata$ChoicePayoff.17.[i]
  jump<-17}
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PrevEarnA[count+18]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PrevEarnA[count+19]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PrevEarnA[count+20]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PrevEarnA[count+21]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PrevEarnA[count+22]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PrevEarnA[count+23]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PrevEarnA[count+24]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PrevEarnA[count+25]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevEarnA<-c(PrevEarnA[1:1457])
tail(PrevEarnA, 38)
table(PrevEarnA)

#PrevAccA is a 1x1735 vector 
PrevAccA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  PrevAccA[count]<-0
  PrevAccA[count+1]<-mydata$AccidentHistory.1.[i]
  PrevAccA[count+2]<-mydata$AccidentHistory.2.[i]
  PrevAccA[count+3]<-mydata$AccidentHistory.3.[i]
  PrevAccA[count+4]<-mydata$AccidentHistory.4.[i]
  PrevAccA[count+5]<-mydata$AccidentHistory.5.[i]
  PrevAccA[count+6]<-mydata$AccidentHistory.6.[i]
  PrevAccA[count+7]<-mydata$AccidentHistory.7.[i]
  PrevAccA[count+8]<-mydata$AccidentHistory.8.[i]
  PrevAccA[count+9]<-mydata$AccidentHistory.9.[i]
  PrevAccA[count+10]<-mydata$AccidentHistory.10.[i]
  PrevAccA[count+11]<-mydata$AccidentHistory.11.[i]
  PrevAccA[count+12]<-mydata$AccidentHistory.12.[i]
  PrevAccA[count+13]<-mydata$AccidentHistory.13.[i]
  PrevAccA[count+14]<-mydata$AccidentHistory.14.[i]
  PrevAccA[count+15]<-mydata$AccidentHistory.15.[i]
  PrevAccA[count+16]<-mydata$AccidentHistory.16.[i]
  jump<-16
  if(is.na(mydata$AccidentHistory.17.[i])==FALSE){PrevAccA[count+17]<-mydata$AccidentHistory.17.[i]
  jump<-17}
  if(is.na(mydata$AccidentHistory.18.[i])==FALSE){PrevAccA[count+18]<-mydata$AccidentHistory.18.[i]
  jump<-18}
  if(is.na(mydata$AccidentHistory.19.[i])==FALSE){PrevAccA[count+19]<-mydata$AccidentHistory.19.[i]
  jump<-19}
  if(is.na(mydata$AccidentHistory.20.[i])==FALSE){PrevAccA[count+20]<-mydata$AccidentHistory.20.[i]
  jump<-20}
  if(is.na(mydata$AccidentHistory.21.[i])==FALSE){PrevAccA[count+21]<-mydata$AccidentHistory.21.[i]
  jump<-21}
  if(is.na(mydata$AccidentHistory.22.[i])==FALSE){PrevAccA[count+22]<-mydata$AccidentHistory.22.[i]
  jump<-22}
  if(is.na(mydata$AccidentHistory.23.[i])==FALSE){PrevAccA[count+23]<-mydata$AccidentHistory.23.[i]
  jump<-23}
  if(is.na(mydata$AccidentHistory.24.[i])==FALSE){PrevAccA[count+24]<-mydata$AccidentHistory.24.[i]
  jump<-24}
  if(is.na(mydata$AccidentHistory.25.[i])==FALSE){PrevAccA[count+25]<-mydata$AccidentHistory.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevAccA<-c(PrevAccA[1:1457])
tail(PrevAccA, 38)
table(PrevAccA)

#PrevGuessAccA is a 1x1735 vector 
PrevGuessAccA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  PrevGuessAccA[count]<-0
  PrevGuessAccA[count+1]<-mydata$GuessPayoff.1.[i]
  PrevGuessAccA[count+2]<-mydata$GuessPayoff.2.[i]
  PrevGuessAccA[count+3]<-mydata$GuessPayoff.3.[i]
  PrevGuessAccA[count+4]<-mydata$GuessPayoff.4.[i]
  PrevGuessAccA[count+5]<-mydata$GuessPayoff.5.[i]
  PrevGuessAccA[count+6]<-mydata$GuessPayoff.6.[i]
  PrevGuessAccA[count+7]<-mydata$GuessPayoff.7.[i]
  PrevGuessAccA[count+8]<-mydata$GuessPayoff.8.[i]
  PrevGuessAccA[count+9]<-mydata$GuessPayoff.9.[i]
  PrevGuessAccA[count+10]<-mydata$GuessPayoff.10.[i]
  PrevGuessAccA[count+11]<-mydata$GuessPayoff.11.[i]
  PrevGuessAccA[count+12]<-mydata$GuessPayoff.12.[i]
  PrevGuessAccA[count+13]<-mydata$GuessPayoff.13.[i]
  PrevGuessAccA[count+14]<-mydata$GuessPayoff.14.[i]
  PrevGuessAccA[count+15]<-mydata$GuessPayoff.15.[i]
  PrevGuessAccA[count+16]<-mydata$GuessPayoff.16.[i]
  jump<-16
  if(is.na(mydata$GuessPayoff.17.[i])==FALSE){PrevGuessAccA[count+17]<-mydata$GuessPayoff.17.[i]
  jump<-17}
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){PrevGuessAccA[count+18]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){PrevGuessAccA[count+19]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){PrevGuessAccA[count+20]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){PrevGuessAccA[count+21]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){PrevGuessAccA[count+22]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){PrevGuessAccA[count+23]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){PrevGuessAccA[count+24]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){PrevGuessAccA[count+25]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevGuessAccA<-c(PrevGuessAccA[1:1457])
tail(PrevGuessAccA, 38)
table(PrevGuessAccA)

#GuessAccA is a 1x1735 vector 
GuessAccA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  GuessAccA[count]<-mydata$GuessPayoff.1.[i]
  GuessAccA[count+1]<-mydata$GuessPayoff.2.[i]
  GuessAccA[count+2]<-mydata$GuessPayoff.3.[i]
  GuessAccA[count+3]<-mydata$GuessPayoff.4.[i]
  GuessAccA[count+4]<-mydata$GuessPayoff.5.[i]
  GuessAccA[count+5]<-mydata$GuessPayoff.6.[i]
  GuessAccA[count+6]<-mydata$GuessPayoff.7.[i]
  GuessAccA[count+7]<-mydata$GuessPayoff.8.[i]
  GuessAccA[count+8]<-mydata$GuessPayoff.9.[i]
  GuessAccA[count+9]<-mydata$GuessPayoff.10.[i]
  GuessAccA[count+10]<-mydata$GuessPayoff.11.[i]
  GuessAccA[count+11]<-mydata$GuessPayoff.12.[i]
  GuessAccA[count+12]<-mydata$GuessPayoff.13.[i]
  GuessAccA[count+13]<-mydata$GuessPayoff.14.[i]
  GuessAccA[count+14]<-mydata$GuessPayoff.15.[i]
  GuessAccA[count+15]<-mydata$GuessPayoff.16.[i]
  GuessAccA[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessAccA[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessAccA[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessAccA[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessAccA[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessAccA[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessAccA[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessAccA[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessAccA[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessAccA, 46)
table(GuessAccA)

#SexA is a 1x1703 vector 
SexA<-numeric(NumObsAssoc)
RiskA<-numeric(NumObsAssoc)
AgeA<-numeric(NumObsAssoc)
StudentTypeA<-numeric(NumObsAssoc)
StudyA<-numeric(NumObsAssoc)
DrivingA<-numeric(NumObsAssoc)
LearningA<-numeric(NumObsAssoc)
NormA<-numeric(NumObsAssoc)
count<-0
jump<-0
for(i in 1:obs){
  if(mydata$ExpType[i]==3){
    jump<-mydata$totper[i]-1
    for(j in 1:jump){
      SexA[count+j]<-mydata$sex[i]
      RiskA[count+j]<-mydata$RiskScore[i]
      AgeA[count+j]<-mydata$age[i]
      StudentTypeA[count+j]<-mydata$student[i]
      StudyA[count+j]<-mydata$study[i]
      DrivingA[count+j]<-mydata$Driving[i]
      LearningA[count+j]<-mydata$Learning[i]
      NormA[count+j]<-mydata$NormChoice[i]
    }
    count<-count+jump
  }
}
#turn the 2 values into 0s
for(i in 1:NumObsAssoc){
  if(SexA[i]==2){SexA[i]=0}
  if(StudentTypeA[i]==2){StudentTypeA[i]=0}
  if(DrivingA[i]==2){DrivingA[i]=0}
  if(LearningA[i]==2){LearningA[i]=0}
}
tail(RiskA,19*3+1)



#SexAny is a  vector 
SexAny<-numeric(NumObsAny)
RiskAny<-numeric(NumObsAny)
count<-0
jump<-0
for(i in 1:obs){
  if(mydata$ExpType[i]==2 | mydata$ExpType[i]==3 | mydata$ExpType[i]==4){
    jump<-mydata$totper[i]-1
    for(j in 1:jump){
      SexAny[count+j]<-mydata$sex[i]
      RiskAny[count+j]<-mydata$RiskScore[i]
    }
    count<-count+jump
  }
}
#turn the 2 values into 0s
for(i in 1:NumObsAny){
  if(SexAny[i]==2){SexAny[i]=0}
}

table(SexAny)



#par(mfrow=c(1,1))

### using multinom
#Unused Variables: PrevGuessAccA
dataA<-data.frame(AutoFastSlowA, FastBeliefA, SlowBeliefA, AutoBeliefA, RiskA, SexA, AgeA,PrevEarnA, PrevAccA,LearningA,DrivingA)
mlogitfitA<- multinom(AutoFastSlowA~FastBeliefA+SlowBeliefA+ AutoBeliefA+ RiskA+ SexA+ PrevEarnA + PrevAccA + LearningA+DrivingA, data=dataA)
summary(mlogitfitA)
z <- summary(mlogitfitA)$coefficients/summary(mlogitfitA)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p

stargazer(mlogitfitA,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))




#How do people make decisions in the Punishment environment?

#AutoFastSlowP is a 1x1735 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  AutoFastSlowP[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowP[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowP[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowP[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowP[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowP[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowP[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowP[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowP[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowP[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowP[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowP[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowP[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowP[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowP[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowP[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowP[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowP[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowP[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowP[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowP[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowP[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowP[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowP[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowP[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

tail(AutoFastSlowP, 46)
table(AutoFastSlowP)
#Change numbers to names (optional)
for(i in 1:NumObsPun){ifelse(AutoFastSlowP[i]==1, AutoFastSlowP[i]<-"Fast", ifelse(AutoFastSlowP[i]==2, AutoFastSlowP[i]<-0, AutoFastSlowP[i]<-'Auto'))}

counts <- c(45.98-46.69, 48.74-46.69, 44.5-46.69)
barplot(counts, main="Car Distribution", 
        xlab="Number of Gears",ylim=c(-5,5)) 

# create a dataset
driving1=c(rep("Fast" , 3) , rep("Slow" , 3) , rep("Auto" , 3))
driving  = factor(driving1, levels=c("Auto", "Slow", "Fast"))
condition1=rep(c("Framing" , "Exogenous" , "Endogenous") , 3)
condition  = factor(condition1, levels=c("Framing", "Exogenous", "Endogenous"))
value=c(45.98-46.69,48.74-46.69, 44.5-46.69,21-19.71,   20.79-19.71,  23.69-19.71, 33.01-33.6,30.48-33.6, 31.82-33.6 )
data=data.frame(driving,condition,value)

# Grouped
ggplot(data, aes(fill=condition, y=value, x=driving))+ 
  geom_bar(position="dodge", stat="identity")+ ylab("Percent difference from Control condition")+ xlab("") 


#DecTimeP is a 1x1735 vector 
DecTimeP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  DecTimeP[count]<-mydata$DecTime.1.[i]
  DecTimeP[count+1]<-mydata$DecTime.2.[i]
  DecTimeP[count+2]<-mydata$DecTime.3.[i]
  DecTimeP[count+3]<-mydata$DecTime.4.[i]
  DecTimeP[count+4]<-mydata$DecTime.5.[i]
  DecTimeP[count+5]<-mydata$DecTime.6.[i]
  DecTimeP[count+6]<-mydata$DecTime.7.[i]
  DecTimeP[count+7]<-mydata$DecTime.8.[i]
  DecTimeP[count+8]<-mydata$DecTime.9.[i]
  DecTimeP[count+9]<-mydata$DecTime.10.[i]
  DecTimeP[count+10]<-mydata$DecTime.11.[i]
  DecTimeP[count+11]<-mydata$DecTime.12.[i]
  DecTimeP[count+12]<-mydata$DecTime.13.[i]
  DecTimeP[count+13]<-mydata$DecTime.14.[i]
  DecTimeP[count+14]<-mydata$DecTime.15.[i]
  DecTimeP[count+15]<-mydata$DecTime.16.[i]
  DecTimeP[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeP[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeP[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeP[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeP[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeP[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeP[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeP[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeP[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#DecTimeP <- DecTimeP[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(DecTimeP, 46)
table(DecTimeP)

#Contribute is a 1x1735 vector 
Contribute<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  Contribute[count]<-mydata$PunishmentChoice.1.[i]
  Contribute[count+1]<-mydata$PunishmentChoice.2.[i]
  Contribute[count+2]<-mydata$PunishmentChoice.3.[i]
  Contribute[count+3]<-mydata$PunishmentChoice.4.[i]
  Contribute[count+4]<-mydata$PunishmentChoice.5.[i]
  Contribute[count+5]<-mydata$PunishmentChoice.6.[i]
  Contribute[count+6]<-mydata$PunishmentChoice.7.[i]
  Contribute[count+7]<-mydata$PunishmentChoice.8.[i]
  Contribute[count+8]<-mydata$PunishmentChoice.9.[i]
  Contribute[count+9]<-mydata$PunishmentChoice.10.[i]
  Contribute[count+10]<-mydata$PunishmentChoice.11.[i]
  Contribute[count+11]<-mydata$PunishmentChoice.12.[i]
  Contribute[count+12]<-mydata$PunishmentChoice.13.[i]
  Contribute[count+13]<-mydata$PunishmentChoice.14.[i]
  Contribute[count+14]<-mydata$PunishmentChoice.15.[i]
  Contribute[count+15]<-mydata$PunishmentChoice.16.[i]
  Contribute[count+16]<-mydata$PunishmentChoice.17.[i]
  jump<-17
  if(is.na(mydata$PunishmentChoice.18.[i])==FALSE){Contribute[count+17]<-mydata$PunishmentChoice.18.[i]
  jump<-18}
  if(is.na(mydata$PunishmentChoice.19.[i])==FALSE){Contribute[count+18]<-mydata$PunishmentChoice.19.[i]
  jump<-19}
  if(is.na(mydata$PunishmentChoice.20.[i])==FALSE){Contribute[count+19]<-mydata$PunishmentChoice.20.[i]
  jump<-20}
  if(is.na(mydata$PunishmentChoice.21.[i])==FALSE){Contribute[count+20]<-mydata$PunishmentChoice.21.[i]
  jump<-21}
  if(is.na(mydata$PunishmentChoice.22.[i])==FALSE){Contribute[count+21]<-mydata$PunishmentChoice.22.[i]
  jump<-22}
  if(is.na(mydata$PunishmentChoice.23.[i])==FALSE){Contribute[count+22]<-mydata$PunishmentChoice.23.[i]
  jump<-23}
  if(is.na(mydata$PunishmentChoice.24.[i])==FALSE){Contribute[count+23]<-mydata$PunishmentChoice.24.[i]
  jump<-24}
  if(is.na(mydata$PunishmentChoice.25.[i])==FALSE){Contribute[count+24]<-mydata$PunishmentChoice.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#Contribute <- Contribute[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(Contribute, 46)
table(Contribute)

mytable <- table(Contribute, AutoFastSlowP) # A will be rows, B will be columns 
mytable # print table 


mytable <- table(Contribute, SexIP) # A will be rows, B will be columns 
mytable # print table


mytable <- table(Contribute, RiskP) # A will be rows, B will be columns 
mytable # print table


margin.table(mytable, 1) # A frequencies (summed over B) 
margin.table(mytable, 2) # B frequencies (summed over A)

prop.table(mytable) # cell percentages
prop.table(mytable, 1) # row percentages 
prop.table(mytable, 2) # column percentages

sum(FastOrNotC)/NumObsControl

table(AutoFastSlowC)
table(AutoFastSlowF)
table(AutoFastSlowA)
table(AutoFastSlowP)


prop.table(table(AutoFastSlowC)) # cell percentages
prop.table(table(AutoFastSlowF))
prop.table(table(AutoFastSlowA))
prop.table(table(AutoFastSlowP))


prop.table(mytable, 1) # row percentages 
prop.table(mytable, 2) # column percentages


PunProp<-c(0.2,0.2,	0.211764706,	0.2,	0.152941176,	0.094117647,	0.164705882,	0.094117647,	0.117647059,	0.094117647,	0.094117647,	0.094117647,	0.105882353,	0.082352941,	0.058823529	,0.070588235,	0.058823529	,0.082352941,	0.118421053,	0.039473684,	0.092307692,	0.075471698,	0.047619048,	0
)
Round<-c(1:24)

df3<-data.frame(Round,PunProp)

ggplot(df3, aes(x=Round, y=PunProp))+ geom_point(color = "red")+
  theme_classic() +ylab("Proportion of subjects who contribute")




#FastBeliefP is a 1x1735 vector 
FastBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  FastBeliefP[count]<-mydata$GuessFast.1.[i]
  FastBeliefP[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefP[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefP[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefP[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefP[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefP[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefP[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefP[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefP[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefP[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefP[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefP[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefP[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefP[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefP[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefP[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefP[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefP[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefP[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefP[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefP[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefP[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefP[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefP[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(FastBeliefP, 46)
table(FastBeliefP)

#SlowBeliefP is a 1x1735 vector 
SlowBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  SlowBeliefP[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefP[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefP[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefP[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefP[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefP[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefP[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefP[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefP[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefP[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefP[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefP[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefP[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefP[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefP[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefP[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefP[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefP[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefP[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefP[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefP[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefP[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefP[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefP[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefP[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(SlowBeliefP, 46)
table(SlowBeliefP)

#AutoBeliefP is a 1x1735 vector 
AutoBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  AutoBeliefP[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefP[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefP[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefP[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefP[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefP[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefP[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefP[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefP[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefP[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefP[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefP[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefP[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefP[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefP[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefP[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefP[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefP[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefP[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefP[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefP[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefP[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefP[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefP[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefP[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(AutoBeliefP, 46)
table(AutoBeliefP)


#PrevEarnP is a  vector 
PrevEarnP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PrevEarnP[count]<-0
  PrevEarnP[count+1]<-mydata$ChoicePayoff.1.[i]
  PrevEarnP[count+2]<-mydata$ChoicePayoff.2.[i]
  PrevEarnP[count+3]<-mydata$ChoicePayoff.3.[i]
  PrevEarnP[count+4]<-mydata$ChoicePayoff.4.[i]
  PrevEarnP[count+5]<-mydata$ChoicePayoff.5.[i]
  PrevEarnP[count+6]<-mydata$ChoicePayoff.6.[i]
  PrevEarnP[count+7]<-mydata$ChoicePayoff.7.[i]
  PrevEarnP[count+8]<-mydata$ChoicePayoff.8.[i]
  PrevEarnP[count+9]<-mydata$ChoicePayoff.9.[i]
  PrevEarnP[count+10]<-mydata$ChoicePayoff.10.[i]
  PrevEarnP[count+11]<-mydata$ChoicePayoff.11.[i]
  PrevEarnP[count+12]<-mydata$ChoicePayoff.12.[i]
  PrevEarnP[count+13]<-mydata$ChoicePayoff.13.[i]
  PrevEarnP[count+14]<-mydata$ChoicePayoff.14.[i]
  PrevEarnP[count+15]<-mydata$ChoicePayoff.15.[i]
  PrevEarnP[count+16]<-mydata$ChoicePayoff.16.[i]
  jump<-16
  if(is.na(mydata$ChoicePayoff.17.[i])==FALSE){PrevEarnP[count+17]<-mydata$ChoicePayoff.17.[i]
  jump<-17}
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PrevEarnP[count+18]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PrevEarnP[count+19]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PrevEarnP[count+20]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PrevEarnP[count+21]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PrevEarnP[count+22]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PrevEarnP[count+23]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PrevEarnP[count+24]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PrevEarnP[count+25]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevEarnP<-c(PrevEarnP[1:1854])
tail(PrevEarnP, 38)
table(PrevEarnP)


#PrevAccP is a 1x1735 vector 
PrevAccP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PrevAccP[count]<-0
  PrevAccP[count+1]<-mydata$AccidentHistory.1.[i]
  PrevAccP[count+2]<-mydata$AccidentHistory.2.[i]
  PrevAccP[count+3]<-mydata$AccidentHistory.3.[i]
  PrevAccP[count+4]<-mydata$AccidentHistory.4.[i]
  PrevAccP[count+5]<-mydata$AccidentHistory.5.[i]
  PrevAccP[count+6]<-mydata$AccidentHistory.6.[i]
  PrevAccP[count+7]<-mydata$AccidentHistory.7.[i]
  PrevAccP[count+8]<-mydata$AccidentHistory.8.[i]
  PrevAccP[count+9]<-mydata$AccidentHistory.9.[i]
  PrevAccP[count+10]<-mydata$AccidentHistory.10.[i]
  PrevAccP[count+11]<-mydata$AccidentHistory.11.[i]
  PrevAccP[count+12]<-mydata$AccidentHistory.12.[i]
  PrevAccP[count+13]<-mydata$AccidentHistory.13.[i]
  PrevAccP[count+14]<-mydata$AccidentHistory.14.[i]
  PrevAccP[count+15]<-mydata$AccidentHistory.15.[i]
  PrevAccP[count+16]<-mydata$AccidentHistory.16.[i]
  jump<-16
  if(is.na(mydata$AccidentHistory.17.[i])==FALSE){PrevAccP[count+17]<-mydata$AccidentHistory.17.[i]
  jump<-17}
  if(is.na(mydata$AccidentHistory.18.[i])==FALSE){PrevAccP[count+18]<-mydata$AccidentHistory.18.[i]
  jump<-18}
  if(is.na(mydata$AccidentHistory.19.[i])==FALSE){PrevAccP[count+19]<-mydata$AccidentHistory.19.[i]
  jump<-19}
  if(is.na(mydata$AccidentHistory.20.[i])==FALSE){PrevAccP[count+20]<-mydata$AccidentHistory.20.[i]
  jump<-20}
  if(is.na(mydata$AccidentHistory.21.[i])==FALSE){PrevAccP[count+21]<-mydata$AccidentHistory.21.[i]
  jump<-21}
  if(is.na(mydata$AccidentHistory.22.[i])==FALSE){PrevAccP[count+22]<-mydata$AccidentHistory.22.[i]
  jump<-22}
  if(is.na(mydata$AccidentHistory.23.[i])==FALSE){PrevAccP[count+23]<-mydata$AccidentHistory.23.[i]
  jump<-23}
  if(is.na(mydata$AccidentHistory.24.[i])==FALSE){PrevAccP[count+24]<-mydata$AccidentHistory.24.[i]
  jump<-24}
  if(is.na(mydata$AccidentHistory.25.[i])==FALSE){PrevAccP[count+25]<-mydata$AccidentHistory.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevAccP<-c(PrevAccP[1:1854])
tail(PrevAccP, 38)
table(PrevAccP)

#PrevGuessAccP is a 1x1735 vector 
PrevGuessAccP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PrevGuessAccP[count]<-0
  PrevGuessAccP[count+1]<-mydata$GuessPayoff.1.[i]
  PrevGuessAccP[count+2]<-mydata$GuessPayoff.2.[i]
  PrevGuessAccP[count+3]<-mydata$GuessPayoff.3.[i]
  PrevGuessAccP[count+4]<-mydata$GuessPayoff.4.[i]
  PrevGuessAccP[count+5]<-mydata$GuessPayoff.5.[i]
  PrevGuessAccP[count+6]<-mydata$GuessPayoff.6.[i]
  PrevGuessAccP[count+7]<-mydata$GuessPayoff.7.[i]
  PrevGuessAccP[count+8]<-mydata$GuessPayoff.8.[i]
  PrevGuessAccP[count+9]<-mydata$GuessPayoff.9.[i]
  PrevGuessAccP[count+10]<-mydata$GuessPayoff.10.[i]
  PrevGuessAccP[count+11]<-mydata$GuessPayoff.11.[i]
  PrevGuessAccP[count+12]<-mydata$GuessPayoff.12.[i]
  PrevGuessAccP[count+13]<-mydata$GuessPayoff.13.[i]
  PrevGuessAccP[count+14]<-mydata$GuessPayoff.14.[i]
  PrevGuessAccP[count+15]<-mydata$GuessPayoff.15.[i]
  PrevGuessAccP[count+16]<-mydata$GuessPayoff.16.[i]
  jump<-16
  if(is.na(mydata$GuessPayoff.17.[i])==FALSE){PrevGuessAccP[count+17]<-mydata$GuessPayoff.17.[i]
  jump<-17}
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){PrevGuessAccP[count+18]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){PrevGuessAccP[count+19]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){PrevGuessAccP[count+20]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){PrevGuessAccP[count+21]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){PrevGuessAccP[count+22]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){PrevGuessAccP[count+23]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){PrevGuessAccP[count+24]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){PrevGuessAccP[count+25]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
PrevGuessAccP<-c(PrevGuessAccP[1:1854])
tail(PrevGuessAccP, 38)
table(PrevGuessAccP)

#GuessAccP is a 1x1735 vector 
GuessAccP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  GuessAccP[count]<-mydata$GuessPayoff.1.[i]
  GuessAccP[count+1]<-mydata$GuessPayoff.2.[i]
  GuessAccP[count+2]<-mydata$GuessPayoff.3.[i]
  GuessAccP[count+3]<-mydata$GuessPayoff.4.[i]
  GuessAccP[count+4]<-mydata$GuessPayoff.5.[i]
  GuessAccP[count+5]<-mydata$GuessPayoff.6.[i]
  GuessAccP[count+6]<-mydata$GuessPayoff.7.[i]
  GuessAccP[count+7]<-mydata$GuessPayoff.8.[i]
  GuessAccP[count+8]<-mydata$GuessPayoff.9.[i]
  GuessAccP[count+9]<-mydata$GuessPayoff.10.[i]
  GuessAccP[count+10]<-mydata$GuessPayoff.11.[i]
  GuessAccP[count+11]<-mydata$GuessPayoff.12.[i]
  GuessAccP[count+12]<-mydata$GuessPayoff.13.[i]
  GuessAccP[count+13]<-mydata$GuessPayoff.14.[i]
  GuessAccP[count+14]<-mydata$GuessPayoff.15.[i]
  GuessAccP[count+15]<-mydata$GuessPayoff.16.[i]
  GuessAccP[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessAccP[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessAccP[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessAccP[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessAccP[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessAccP[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessAccP[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessAccP[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessAccP[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessAccP, 46)
table(GuessAccP)

#SexP is a 1x1703 vector 
SexP<-numeric(NumObsPun)
RiskP<-numeric(NumObsPun)
AgeP<-numeric(NumObsPun)
StudentTypeP<-numeric(NumObsPun)
StudyP<-numeric(NumObsPun)
DrivingP<-numeric(NumObsPun)
LearningP<-numeric(NumObsPun)
NormP<-numeric(NumObsPun)
count<-0
jump<-0
for(i in 1:obs){
  if(mydata$ExpType[i]==4){
    jump<-mydata$totper[i]-1
    for(j in 1:jump){
      SexP[count+j]<-mydata$sex[i]
      RiskP[count+j]<-mydata$RiskScore[i]
      AgeP[count+j]<-mydata$age[i]
      StudentTypeP[count+j]<-mydata$student[i]
      StudyP[count+j]<-mydata$study[i]
      DrivingP[count+j]<-mydata$Driving[i]
      LearningP[count+j]<-mydata$Learning[i]
      NormP[count+j]<-mydata$NormChoice[i]
    }
    count<-count+jump
  }
}
#turn the 2 values into 0s
for(i in 1:NumObsPun){
  if(SexP[i]==2){SexP[i]=0}
  if(StudentTypeP[i]==2){StudentTypeP[i]=0}
  if(DrivingP[i]==2){DrivingP[i]=0}
  if(LearningP[i]==2){LearningP[i]=0}
}
tail(RiskP,19*3+1)

#par(mfrow=c(1,1))

### using multinom
#Unused Variables: PrevGuessAccA
dataP<-data.frame(AutoFastSlowP, FastBeliefP, SlowBeliefP, AutoBeliefP, RiskP, SexP, AgeP, PrevEarnP,PrevAccP, LearningP, DrivingP)
mlogitfitP<- multinom(AutoFastSlowP~FastBeliefP+SlowBeliefP+ AutoBeliefP+RiskP+ SexP+ PrevEarnP + PrevAccP + LearningP+DrivingP, data=dataP)
summary(mlogitfitP)
z <- summary(mlogitfitP)$coefficients/summary(mlogitfitP)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p


stargazer(mlogitfitP,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))

stargazer(mlogitfitC,mlogitfitF,mlogitfitA,mlogitfitP,dep.var.caption  = "Choice (relative to Slow)",title="Baseline + Controls", report=('vc*p'))


#Total payoffs by treatment

#PayoffC is a 1x1735 vector 
PayoffC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PayoffC[count]<-mydata$ChoicePayoff.1.[i]
  PayoffC[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffC[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffC[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffC[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffC[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffC[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffC[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffC[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffC[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffC[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffC[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffC[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffC[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffC[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffC[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffC[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffC[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffC[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffC[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffC[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffC[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffC[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffC[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffC[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffC, 46)
table(PayoffC)


#PayoffCF is a 1xFemaleControl vector 
PayoffCF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==2){
  PayoffCF[count]<-mydata$ChoicePayoff.1.[i]
  PayoffCF[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffCF[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffCF[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffCF[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffCF[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffCF[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffCF[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffCF[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffCF[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffCF[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffCF[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffCF[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffCF[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffCF[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffCF[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffCF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffCF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffCF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffCF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffCF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffCF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffCF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffCF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffCF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffCF, 46)
table(PayoffCF)


#PayoffCM is a 1xMaleControl vector 
PayoffCM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==1){
  PayoffCM[count]<-mydata$ChoicePayoff.1.[i]
  PayoffCM[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffCM[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffCM[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffCM[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffCM[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffCM[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffCM[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffCM[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffCM[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffCM[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffCM[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffCM[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffCM[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffCM[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffCM[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffCM[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffCM[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffCM[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffCM[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffCM[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffCM[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffCM[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffCM[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffCM[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffCM, 46)
table(PayoffCM)
mean(PayoffCF)
mean(PayoffCM)

#GuessPayoffC is a 1x1735 vector 
GuessPayoffC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  GuessPayoffC[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffC[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffC[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffC[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffC[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffC[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffC[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffC[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffC[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffC[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffC[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffC[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffC[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffC[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffC[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffC[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffC[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffC[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffC[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffC[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffC[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffC[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffC[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffC[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffC[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffC, 46)
table(GuessPayoffC)


#GuessPayoffCF is a 1xFEmobs vector 
GuessPayoffCF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==2){
  GuessPayoffCF[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffCF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffCF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffCF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffCF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffCF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffCF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffCF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffCF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffCF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffCF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffCF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffCF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffCF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffCF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffCF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffCF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffCF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffCF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffCF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffCF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffCF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffCF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffCF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffCF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffCF, 46)
table(GuessPayoffCF)


#GuessPayoffCM is a 1xFEmobs vector 
GuessPayoffCM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==1){
  GuessPayoffCM[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffCM[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffCM[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffCM[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffCM[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffCM[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffCM[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffCM[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffCM[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffCM[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffCM[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffCM[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffCM[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffCM[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffCM[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffCM[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffCM[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffCM[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffCM[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffCM[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffCM[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffCM[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffCM[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffCM[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffCM[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffCM, 46)
table(GuessPayoffCM)
t.test(GuessPayoffCF,GuessPayoffCM)

GuessPayoffAny<-numeric(50)
GuessPayoffAny<-c(GuessPayoffP, GuessPayoffF, GuessPayoffA)
mean(GuessPayoffAny)

GuessPayoffAnyM<-numeric(50)
GuessPayoffAnyM<-c(GuessPayoffPM, GuessPayoffFM, GuessPayoffAM)

GuessPayoffAnyF<-numeric(50)
GuessPayoffAnyF<-c(GuessPayoffPF, GuessPayoffFF, GuessPayoffAF)

t.test(GuessPayoffCM,GuessPayoffCF)
t.test(GuessPayoffPM,GuessPayoffPF)
t.test(GuessPayoffFM,GuessPayoffFF)
t.test(GuessPayoffAM,GuessPayoffAF)
t.test(GuessPayoffAnyM,GuessPayoffAnyF)




#PayoffF is a 1x1735 vector 
PayoffF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  PayoffF[count]<-mydata$ChoicePayoff.1.[i]
  PayoffF[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffF[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffF[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffF[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffF[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffF[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffF[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffF[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffF[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffF[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffF[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffF[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffF[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffF[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffF[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffF, 46)
table(PayoffF)

#PayoffFF is a 1xFemaleControl vector 
PayoffFF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==2){
  PayoffFF[count]<-mydata$ChoicePayoff.1.[i]
  PayoffFF[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffFF[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffFF[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffFF[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffFF[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffFF[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffFF[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffFF[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffFF[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffFF[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffFF[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffFF[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffFF[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffFF[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffFF[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffFF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffFF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffFF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffFF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffFF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffFF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffFF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffFF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffFF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffFF, 46)
table(PayoffFF)


#PayoffFM is a 1xFemaleControl vector 
PayoffFM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==1){
  PayoffFM[count]<-mydata$ChoicePayoff.1.[i]
  PayoffFM[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffFM[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffFM[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffFM[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffFM[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffFM[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffFM[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffFM[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffFM[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffFM[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffFM[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffFM[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffFM[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffFM[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffFM[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffFM[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffFM[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffFM[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffFM[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffFM[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffFM[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffFM[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffFM[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffFM[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffFM, 46)
table(PayoffFM)

mean(PayoffFM)
mean(PayoffFF)
t.test(PayoffFM,PayoffFF)

#GuessPayoffF is a 1x1735 vector 
GuessPayoffF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  GuessPayoffF[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffF, 46)
table(GuessPayoffF)


#GuessPayoffFF is a 1xFEmobs vector 
GuessPayoffFF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==2){
  GuessPayoffFF[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffFF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffFF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffFF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffFF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffFF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffFF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffFF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffFF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffFF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffFF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffFF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffFF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffFF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffFF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffFF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffFF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffFF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffFF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffFF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffFF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffFF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffFF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffFF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffFF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffFF, 46)
table(GuessPayoffFF)


#GuessPayoffFM is a 1xFEmobs vector 
GuessPayoffFM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==1){
  GuessPayoffFM[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffFM[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffFM[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffFM[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffFM[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffFM[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffFM[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffFM[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffFM[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffFM[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffFM[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffFM[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffFM[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffFM[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffFM[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffFM[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffFM[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffFM[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffFM[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffFM[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffFM[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffFM[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffFM[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffFM[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffFM[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffFM, 46)
table(GuessPayoffFM)
t.test(GuessPayoffFM,GuessPayoffFF)

PayoffA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  PayoffA[count]<-mydata$ChoicePayoff.1.[i]
  PayoffA[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffA[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffA[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffA[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffA[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffA[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffA[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffA[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffA[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffA[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffA[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffA[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffA[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffA[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffA[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffA[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffA[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffA[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffA[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffA[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffA[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffA[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffA[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffA[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffA, 46)
table(PayoffA)


#PayoffAF is a 1xFemaleControl vector 
PayoffAF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==2){
  PayoffAF[count]<-mydata$ChoicePayoff.1.[i]
  PayoffAF[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffAF[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffAF[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffAF[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffAF[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffAF[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffAF[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffAF[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffAF[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffAF[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffAF[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffAF[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffAF[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffAF[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffAF[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffAF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffAF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffAF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffAF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffAF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffAF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffAF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffAF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffAF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffAF, 46)
table(PayoffAF)


#PayoffAM is a 1xFemaleControl vector 
PayoffAM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==1){
  PayoffAM[count]<-mydata$ChoicePayoff.1.[i]
  PayoffAM[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffAM[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffAM[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffAM[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffAM[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffAM[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffAM[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffAM[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffAM[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffAM[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffAM[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffAM[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffAM[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffAM[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffAM[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffAM[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffAM[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffAM[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffAM[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffAM[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffAM[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffAM[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffAM[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffAM[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffAM, 46)
table(PayoffAM)

mean(PayoffAM)
mean(PayoffAF)
t.test(PayoffAM,PayoffAF)



GuessPayoffA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  GuessPayoffA[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffA[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffA[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffA[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffA[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffA[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffA[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffA[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffA[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffA[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffA[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffA[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffA[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffA[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffA[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffA[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffA[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffA[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffA[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffA[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffA[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffA[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffA[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffA[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffA[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffA, 46)
table(GuessPayoffA)


#GuessPayoffAF is a 1xFEmobs vector 
GuessPayoffAF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==2){
  GuessPayoffAF[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffAF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffAF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffAF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffAF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffAF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffAF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffAF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffAF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffAF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffAF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffAF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffAF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffAF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffAF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffAF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffAF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffAF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffAF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffAF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffAF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffAF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffAF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffAF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffAF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffAF, 46)
table(GuessPayoffAF)


#GuessPayoffAM is a 1xFEmobs vector 
GuessPayoffAM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==1){
  GuessPayoffAM[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffAM[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffAM[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffAM[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffAM[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffAM[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffAM[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffAM[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffAM[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffAM[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffAM[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffAM[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffAM[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffAM[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffAM[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffAM[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffAM[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffAM[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffAM[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffAM[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffAM[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffAM[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffAM[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffAM[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffAM[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffAM, 46)
table(GuessPayoffAM)

t.test(GuessPayoffAM,GuessPayoffAF)

PayoffP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PayoffP[count]<-mydata$ChoicePayoff.1.[i]
  PayoffP[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffP[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffP[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffP[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffP[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffP[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffP[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffP[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffP[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffP[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffP[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffP[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffP[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffP[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffP[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffP[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffP[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffP[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffP[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffP[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffP[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffP[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffP[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffP[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffP, 46)
table(PayoffP)


#PayoffPF is a 1xFemaleControl vector 
PayoffPF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==2){
  PayoffPF[count]<-mydata$ChoicePayoff.1.[i]
  PayoffPF[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffPF[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffPF[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffPF[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffPF[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffPF[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffPF[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffPF[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffPF[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffPF[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffPF[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffPF[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffPF[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffPF[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffPF[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffPF[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffPF[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffPF[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffPF[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffPF[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffPF[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffPF[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffPF[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffPF[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffPF, 46)
table(PayoffPF)



#PayoffPM is a 1xFemaleControl vector 
PayoffPM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==1){
  PayoffPM[count]<-mydata$ChoicePayoff.1.[i]
  PayoffPM[count+1]<-mydata$ChoicePayoff.2.[i]
  PayoffPM[count+2]<-mydata$ChoicePayoff.3.[i]
  PayoffPM[count+3]<-mydata$ChoicePayoff.4.[i]
  PayoffPM[count+4]<-mydata$ChoicePayoff.5.[i]
  PayoffPM[count+5]<-mydata$ChoicePayoff.6.[i]
  PayoffPM[count+6]<-mydata$ChoicePayoff.7.[i]
  PayoffPM[count+7]<-mydata$ChoicePayoff.8.[i]
  PayoffPM[count+8]<-mydata$ChoicePayoff.9.[i]
  PayoffPM[count+9]<-mydata$ChoicePayoff.10.[i]
  PayoffPM[count+10]<-mydata$ChoicePayoff.11.[i]
  PayoffPM[count+11]<-mydata$ChoicePayoff.12.[i]
  PayoffPM[count+12]<-mydata$ChoicePayoff.13.[i]
  PayoffPM[count+13]<-mydata$ChoicePayoff.14.[i]
  PayoffPM[count+14]<-mydata$ChoicePayoff.15.[i]
  PayoffPM[count+15]<-mydata$ChoicePayoff.16.[i]
  PayoffPM[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PayoffPM[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PayoffPM[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PayoffPM[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PayoffPM[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PayoffPM[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PayoffPM[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PayoffPM[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PayoffPM[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffPM, 46)
table(PayoffPM)


mean(PayoffPM)
mean(PayoffPF)
t.test(PayoffPM,PayoffPF)

t.test(PayoffCM,PayoffCF)
t.test(PayoffFM,PayoffFF)
t.test(PayoffAM,PayoffAF)
t.test(PayoffPAdjM,PayoffPAdjF)

#Calculating 95% CI of each variable Earning variable (Driving choice)

error <- qnorm(0.975)*sd(PayoffC)/sqrt(length(PayoffC))
left <- mean(PayoffC)-error
right <- mean(PayoffC)+error
left
right

error <- qnorm(0.975)*sd(PayoffP)/sqrt(length(PayoffP))
left <- mean(PayoffP)-error
right <- mean(PayoffP)+error
left
right


error <- qnorm(0.975)*sd(PayoffF)/sqrt(length(PayoffF))
left <- mean(PayoffF)-error
right <- mean(PayoffF)+error
left
right


error <- qnorm(0.975)*sd(PayoffA)/sqrt(length(PayoffA))
left <- mean(PayoffA)-error
right <- mean(PayoffA)+error
left
right

error <- qnorm(0.975)*sd(PayoffCM)/sqrt(length(PayoffCM))
left <- mean(PayoffCM)-error
right <- mean(PayoffCM)+error
left
right

error <- qnorm(0.975)*sd(PayoffCF)/sqrt(length(PayoffCF))
left <- mean(PayoffCF)-error
right <- mean(PayoffCF)+error
left
right

error <- qnorm(0.975)*sd(PayoffPM)/sqrt(length(PayoffPM))
left <- mean(PayoffPM)-error
right <- mean(PayoffPM)+error
left
right

error <- qnorm(0.975)*sd(PayoffPF)/sqrt(length(PayoffPF))
left <- mean(PayoffPF)-error
right <- mean(PayoffPF)+error
left
right

#99% CI calculation
error <- qnorm(0.995)*sd(PayoffPM)/sqrt(length(PayoffPM))
left <- mean(PayoffPM)-error
right <- mean(PayoffPM)+error
left
right

error <- qnorm(0.995)*sd(PayoffPF)/sqrt(length(PayoffPF))
left <- mean(PayoffPF)-error
right <- mean(PayoffPF)+error
left
right

error <- qnorm(0.975)*sd(PayoffFM)/sqrt(length(PayoffFM))
left <- mean(PayoffFM)-error
right <- mean(PayoffFM)+error
left
right

error <- qnorm(0.975)*sd(PayoffFF)/sqrt(length(PayoffFF))
left <- mean(PayoffFF)-error
right <- mean(PayoffFF)+error
left
right

error <- qnorm(0.975)*sd(PayoffAM)/sqrt(length(PayoffAM))
left <- mean(PayoffAM)-error
right <- mean(PayoffAM)+error
left
right

error <- qnorm(0.975)*sd(PayoffAF)/sqrt(length(PayoffAF))
left <- mean(PayoffAF)-error
right <- mean(PayoffAF)+error
left
right

#Calculating 95% CI of each variable Earning variable (Guess choice)


error <- qnorm(0.975)*sd(GuessPayoffC)/sqrt(length(GuessPayoffC))
left <- mean(GuessPayoffC)-error
right <- mean(GuessPayoffC)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffP)/sqrt(length(GuessPayoffP))
left <- mean(GuessPayoffP)-error
right <- mean(GuessPayoffP)+error
left
right


error <- qnorm(0.975)*sd(GuessPayoffF)/sqrt(length(GuessPayoffF))
left <- mean(GuessPayoffF)-error
right <- mean(GuessPayoffF)+error
left
right


error <- qnorm(0.975)*sd(GuessPayoffA)/sqrt(length(GuessPayoffA))
left <- mean(GuessPayoffA)-error
right <- mean(GuessPayoffA)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffCM)/sqrt(length(GuessPayoffCM))
left <- mean(GuessPayoffCM)-error
right <- mean(GuessPayoffCM)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffCF)/sqrt(length(GuessPayoffCF))
left <- mean(GuessPayoffCF)-error
right <- mean(GuessPayoffCF)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffPM)/sqrt(length(GuessPayoffPM))
left <- mean(GuessPayoffPM)-error
right <- mean(GuessPayoffPM)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffPF)/sqrt(length(GuessPayoffPF))
left <- mean(GuessPayoffPF)-error
right <- mean(GuessPayoffPF)+error
left
right

#99% CI calculation
error <- qnorm(0.995)*sd(GuessPayoffPM)/sqrt(length(GuessPayoffPM))
left <- mean(GuessPayoffPM)-error
right <- mean(GuessPayoffPM)+error
left
right

error <- qnorm(0.995)*sd(GuessPayoffPF)/sqrt(length(GuessPayoffPF))
left <- mean(GuessPayoffPF)-error
right <- mean(GuessPayoffPF)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffFM)/sqrt(length(GuessPayoffFM))
left <- mean(GuessPayoffFM)-error
right <- mean(GuessPayoffFM)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffFF)/sqrt(length(GuessPayoffFF))
left <- mean(GuessPayoffFF)-error
right <- mean(GuessPayoffFF)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffAM)/sqrt(length(GuessPayoffAM))
left <- mean(GuessPayoffAM)-error
right <- mean(GuessPayoffAM)+error
left
right

error <- qnorm(0.975)*sd(GuessPayoffAF)/sqrt(length(GuessPayoffAF))
left <- mean(GuessPayoffAF)-error
right <- mean(GuessPayoffAF)+error
left
right












t.test(PayoffC,PayoffF)
t.test(PayoffC,PayoffA)
t.test(PayoffC,PayoffPAdj)

table(PayoffPAdj)
# GENDERPAY

#Many obs...
pop1<-PayoffA
pop2<-PayoffAF
pop3<-PayoffAM

# You have to turn the variable into a data frame to use ggplot
pop1.data <- data.frame(pop1)
pop2.data <- data.frame(pop2)
pop3.data <- data.frame(pop3)

pop1.data$type <- NA
pop2.data$type <- NA
pop3.data$type <- NA

pop1.data$type <- 'All'
pop2.data$type <- 'Female'
pop3.data$type <- 'Male'


colnames(pop1.data) <- c("Time", "Condition")
colnames(pop2.data) <- c("Time", "Condition")
colnames(pop3.data) <- c("Time", "Condition")

p1vsp2vsp3<- rbind(pop1.data, pop2.data, pop3.data)

plot1 <- ggplot(p1vsp2vsp3, aes(Time, fill=Condition,linetype=Condition)) + stat_ecdf(aes(colour=Condition)) + labs(x = "Earnings", y = "Proportion")+ 
  theme_classic()+xlim(0,30)#+scale_color_manual(values=c('#000000','#E69F00'))+
#annotation_custom(my_grob1)+xlim(0,100)+ylim(0,1)
plot1








GuessPayoffP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  GuessPayoffP[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffP[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffP[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffP[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffP[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffP[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffP[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffP[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffP[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffP[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffP[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffP[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffP[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffP[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffP[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffP[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffP[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffP[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffP[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffP[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffP[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffP[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffP[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffP[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffP[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffP, 46)
table(GuessPayoffP)


#GuessPayoffPF is a 1xFEmobs vector 
GuessPayoffPF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==2){
  GuessPayoffPF[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffPF[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffPF[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffPF[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffPF[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffPF[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffPF[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffPF[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffPF[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffPF[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffPF[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffPF[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffPF[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffPF[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffPF[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffPF[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffPF[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffPF[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffPF[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffPF[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffPF[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffPF[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffPF[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffPF[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffPF[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffPF, 46)
table(GuessPayoffPF)


#GuessPayoffPM is a 1xFEmobs vector 
GuessPayoffPM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==1){
  GuessPayoffPM[count]<-mydata$GuessPayoff.1.[i]
  GuessPayoffPM[count+1]<-mydata$GuessPayoff.2.[i]
  GuessPayoffPM[count+2]<-mydata$GuessPayoff.3.[i]
  GuessPayoffPM[count+3]<-mydata$GuessPayoff.4.[i]
  GuessPayoffPM[count+4]<-mydata$GuessPayoff.5.[i]
  GuessPayoffPM[count+5]<-mydata$GuessPayoff.6.[i]
  GuessPayoffPM[count+6]<-mydata$GuessPayoff.7.[i]
  GuessPayoffPM[count+7]<-mydata$GuessPayoff.8.[i]
  GuessPayoffPM[count+8]<-mydata$GuessPayoff.9.[i]
  GuessPayoffPM[count+9]<-mydata$GuessPayoff.10.[i]
  GuessPayoffPM[count+10]<-mydata$GuessPayoff.11.[i]
  GuessPayoffPM[count+11]<-mydata$GuessPayoff.12.[i]
  GuessPayoffPM[count+12]<-mydata$GuessPayoff.13.[i]
  GuessPayoffPM[count+13]<-mydata$GuessPayoff.14.[i]
  GuessPayoffPM[count+14]<-mydata$GuessPayoff.15.[i]
  GuessPayoffPM[count+15]<-mydata$GuessPayoff.16.[i]
  GuessPayoffPM[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessPayoffPM[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessPayoffPM[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessPayoffPM[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessPayoffPM[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessPayoffPM[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessPayoffPM[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessPayoffPM[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessPayoffPM[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(GuessPayoffPM, 46)
table(GuessPayoffPM)

t.test(GuessPayoffPM,GuessPayoffPF)



PayoffPAdj<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PayoffPAdj[count]<-mydata$AdjChoicePayoff.1.[i]
  PayoffPAdj[count+1]<-mydata$AdjChoicePayoff.2.[i]
  PayoffPAdj[count+2]<-mydata$AdjChoicePayoff.3.[i]
  PayoffPAdj[count+3]<-mydata$AdjChoicePayoff.4.[i]
  PayoffPAdj[count+4]<-mydata$AdjChoicePayoff.5.[i]
  PayoffPAdj[count+5]<-mydata$AdjChoicePayoff.6.[i]
  PayoffPAdj[count+6]<-mydata$AdjChoicePayoff.7.[i]
  PayoffPAdj[count+7]<-mydata$AdjChoicePayoff.8.[i]
  PayoffPAdj[count+8]<-mydata$AdjChoicePayoff.9.[i]
  PayoffPAdj[count+9]<-mydata$AdjChoicePayoff.10.[i]
  PayoffPAdj[count+10]<-mydata$AdjChoicePayoff.11.[i]
  PayoffPAdj[count+11]<-mydata$AdjChoicePayoff.12.[i]
  PayoffPAdj[count+12]<-mydata$AdjChoicePayoff.13.[i]
  PayoffPAdj[count+13]<-mydata$AdjChoicePayoff.14.[i]
  PayoffPAdj[count+14]<-mydata$AdjChoicePayoff.15.[i]
  PayoffPAdj[count+15]<-mydata$AdjChoicePayoff.16.[i]
  PayoffPAdj[count+16]<-mydata$AdjChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$AdjChoicePayoff.18.[i])==FALSE){PayoffPAdj[count+17]<-mydata$AdjChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$AdjChoicePayoff.19.[i])==FALSE){PayoffPAdj[count+18]<-mydata$AdjChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$AdjChoicePayoff.20.[i])==FALSE){PayoffPAdj[count+19]<-mydata$AdjChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$AdjChoicePayoff.21.[i])==FALSE){PayoffPAdj[count+20]<-mydata$AdjChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$AdjChoicePayoff.22.[i])==FALSE){PayoffPAdj[count+21]<-mydata$AdjChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$AdjChoicePayoff.23.[i])==FALSE){PayoffPAdj[count+22]<-mydata$AdjChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$AdjChoicePayoff.24.[i])==FALSE){PayoffPAdj[count+23]<-mydata$AdjChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$AdjChoicePayoff.25.[i])==FALSE){PayoffPAdj[count+24]<-mydata$AdjChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffPAdj, 46)
table(PayoffPAdj)


PayoffPAdjF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==2){
  PayoffPAdjF[count]<-mydata$AdjChoicePayoff.1.[i]
  PayoffPAdjF[count+1]<-mydata$AdjChoicePayoff.2.[i]
  PayoffPAdjF[count+2]<-mydata$AdjChoicePayoff.3.[i]
  PayoffPAdjF[count+3]<-mydata$AdjChoicePayoff.4.[i]
  PayoffPAdjF[count+4]<-mydata$AdjChoicePayoff.5.[i]
  PayoffPAdjF[count+5]<-mydata$AdjChoicePayoff.6.[i]
  PayoffPAdjF[count+6]<-mydata$AdjChoicePayoff.7.[i]
  PayoffPAdjF[count+7]<-mydata$AdjChoicePayoff.8.[i]
  PayoffPAdjF[count+8]<-mydata$AdjChoicePayoff.9.[i]
  PayoffPAdjF[count+9]<-mydata$AdjChoicePayoff.10.[i]
  PayoffPAdjF[count+10]<-mydata$AdjChoicePayoff.11.[i]
  PayoffPAdjF[count+11]<-mydata$AdjChoicePayoff.12.[i]
  PayoffPAdjF[count+12]<-mydata$AdjChoicePayoff.13.[i]
  PayoffPAdjF[count+13]<-mydata$AdjChoicePayoff.14.[i]
  PayoffPAdjF[count+14]<-mydata$AdjChoicePayoff.15.[i]
  PayoffPAdjF[count+15]<-mydata$AdjChoicePayoff.16.[i]
  PayoffPAdjF[count+16]<-mydata$AdjChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$AdjChoicePayoff.18.[i])==FALSE){PayoffPAdjF[count+17]<-mydata$AdjChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$AdjChoicePayoff.19.[i])==FALSE){PayoffPAdjF[count+18]<-mydata$AdjChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$AdjChoicePayoff.20.[i])==FALSE){PayoffPAdjF[count+19]<-mydata$AdjChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$AdjChoicePayoff.21.[i])==FALSE){PayoffPAdjF[count+20]<-mydata$AdjChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$AdjChoicePayoff.22.[i])==FALSE){PayoffPAdjF[count+21]<-mydata$AdjChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$AdjChoicePayoff.23.[i])==FALSE){PayoffPAdjF[count+22]<-mydata$AdjChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$AdjChoicePayoff.24.[i])==FALSE){PayoffPAdjF[count+23]<-mydata$AdjChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$AdjChoicePayoff.25.[i])==FALSE){PayoffPAdjF[count+24]<-mydata$AdjChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffPAdjF, 46)
table(PayoffPAdjF)


PayoffPAdjM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==1){
  PayoffPAdjM[count]<-mydata$AdjChoicePayoff.1.[i]
  PayoffPAdjM[count+1]<-mydata$AdjChoicePayoff.2.[i]
  PayoffPAdjM[count+2]<-mydata$AdjChoicePayoff.3.[i]
  PayoffPAdjM[count+3]<-mydata$AdjChoicePayoff.4.[i]
  PayoffPAdjM[count+4]<-mydata$AdjChoicePayoff.5.[i]
  PayoffPAdjM[count+5]<-mydata$AdjChoicePayoff.6.[i]
  PayoffPAdjM[count+6]<-mydata$AdjChoicePayoff.7.[i]
  PayoffPAdjM[count+7]<-mydata$AdjChoicePayoff.8.[i]
  PayoffPAdjM[count+8]<-mydata$AdjChoicePayoff.9.[i]
  PayoffPAdjM[count+9]<-mydata$AdjChoicePayoff.10.[i]
  PayoffPAdjM[count+10]<-mydata$AdjChoicePayoff.11.[i]
  PayoffPAdjM[count+11]<-mydata$AdjChoicePayoff.12.[i]
  PayoffPAdjM[count+12]<-mydata$AdjChoicePayoff.13.[i]
  PayoffPAdjM[count+13]<-mydata$AdjChoicePayoff.14.[i]
  PayoffPAdjM[count+14]<-mydata$AdjChoicePayoff.15.[i]
  PayoffPAdjM[count+15]<-mydata$AdjChoicePayoff.16.[i]
  PayoffPAdjM[count+16]<-mydata$AdjChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$AdjChoicePayoff.18.[i])==FALSE){PayoffPAdjM[count+17]<-mydata$AdjChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$AdjChoicePayoff.19.[i])==FALSE){PayoffPAdjM[count+18]<-mydata$AdjChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$AdjChoicePayoff.20.[i])==FALSE){PayoffPAdjM[count+19]<-mydata$AdjChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$AdjChoicePayoff.21.[i])==FALSE){PayoffPAdjM[count+20]<-mydata$AdjChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$AdjChoicePayoff.22.[i])==FALSE){PayoffPAdjM[count+21]<-mydata$AdjChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$AdjChoicePayoff.23.[i])==FALSE){PayoffPAdjM[count+22]<-mydata$AdjChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$AdjChoicePayoff.24.[i])==FALSE){PayoffPAdjM[count+23]<-mydata$AdjChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$AdjChoicePayoff.25.[i])==FALSE){PayoffPAdjM[count+24]<-mydata$AdjChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
}
tail(PayoffPAdjM, 46)
table(PayoffPAdjM)



##PAYOFF TABLES/FIGURES

t.test(PayoffC, PayoffF)
t.test(PayoffC, PayoffA)
t.test(PayoffC, PayoffP)
t.test(PayoffC, PayoffPAdj)

mean(PayoffC)
mean(PayoffF)
mean(PayoffA)
mean(PayoffP)
mean(PayoffPAdj)

mean(GuessPayoffC)
mean(GuessPayoffF)
mean(GuessPayoffA)
mean(GuessPayoffP)

t.test(GuessPayoffC, GuessPayoffA)

##BELIEFS PAYOFF TABLES/FIGURES
t.test(GuessPayoffC, GuessPayoffP)
t.test(GuessPayoffC, GuessPayoffF)
t.test(GuessPayoffC, GuessPayoffA)

t.test(GuessPayoffCF, GuessPayoffCM)
t.test(GuessPayoffPF, GuessPayoffPM)
t.test(GuessPayoffFF, GuessPayoffFM)
t.test(GuessPayoffAF, GuessPayoffAM)







#Creating variables with all treatments

#DecTime is a 1x6749 vector 
DecTime<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  DecTime[count]<-mydata$DecTime.1.[i]
  DecTime[count+1]<-mydata$DecTime.2.[i]
  DecTime[count+2]<-mydata$DecTime.3.[i]
  DecTime[count+3]<-mydata$DecTime.4.[i]
  DecTime[count+4]<-mydata$DecTime.5.[i]
  DecTime[count+5]<-mydata$DecTime.6.[i]
  DecTime[count+6]<-mydata$DecTime.7.[i]
  DecTime[count+7]<-mydata$DecTime.8.[i]
  DecTime[count+8]<-mydata$DecTime.9.[i]
  DecTime[count+9]<-mydata$DecTime.10.[i]
  DecTime[count+10]<-mydata$DecTime.11.[i]
  DecTime[count+11]<-mydata$DecTime.12.[i]
  DecTime[count+12]<-mydata$DecTime.13.[i]
  DecTime[count+13]<-mydata$DecTime.14.[i]
  DecTime[count+14]<-mydata$DecTime.15.[i]
  DecTime[count+15]<-mydata$DecTime.16.[i]
  DecTime[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTime[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTime[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTime[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTime[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTime[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTime[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTime[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTime[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#DecTimeP <- DecTimeP[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
head(DecTime, 500)
table(DecTime)


#DecTimeC is a 1xcontrol vector 
DecTimeC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  DecTimeC[count]<-mydata$DecTime.1.[i]
  DecTimeC[count+1]<-mydata$DecTime.2.[i]
  DecTimeC[count+2]<-mydata$DecTime.3.[i]
  DecTimeC[count+3]<-mydata$DecTime.4.[i]
  DecTimeC[count+4]<-mydata$DecTime.5.[i]
  DecTimeC[count+5]<-mydata$DecTime.6.[i]
  DecTimeC[count+6]<-mydata$DecTime.7.[i]
  DecTimeC[count+7]<-mydata$DecTime.8.[i]
  DecTimeC[count+8]<-mydata$DecTime.9.[i]
  DecTimeC[count+9]<-mydata$DecTime.10.[i]
  DecTimeC[count+10]<-mydata$DecTime.11.[i]
  DecTimeC[count+11]<-mydata$DecTime.12.[i]
  DecTimeC[count+12]<-mydata$DecTime.13.[i]
  DecTimeC[count+13]<-mydata$DecTime.14.[i]
  DecTimeC[count+14]<-mydata$DecTime.15.[i]
  DecTimeC[count+15]<-mydata$DecTime.16.[i]
  DecTimeC[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeC[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeC[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeC[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeC[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeC[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeC[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeC[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeC[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
table(DecTimeC)
mean(DecTimeC)

#DecTimeC is a 1xcontrol vector 
DecTimeCM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==1){
  DecTimeCM[count]<-mydata$DecTime.1.[i]
  DecTimeCM[count+1]<-mydata$DecTime.2.[i]
  DecTimeCM[count+2]<-mydata$DecTime.3.[i]
  DecTimeCM[count+3]<-mydata$DecTime.4.[i]
  DecTimeCM[count+4]<-mydata$DecTime.5.[i]
  DecTimeCM[count+5]<-mydata$DecTime.6.[i]
  DecTimeCM[count+6]<-mydata$DecTime.7.[i]
  DecTimeCM[count+7]<-mydata$DecTime.8.[i]
  DecTimeCM[count+8]<-mydata$DecTime.9.[i]
  DecTimeCM[count+9]<-mydata$DecTime.10.[i]
  DecTimeCM[count+10]<-mydata$DecTime.11.[i]
  DecTimeCM[count+11]<-mydata$DecTime.12.[i]
  DecTimeCM[count+12]<-mydata$DecTime.13.[i]
  DecTimeCM[count+13]<-mydata$DecTime.14.[i]
  DecTimeCM[count+14]<-mydata$DecTime.15.[i]
  DecTimeCM[count+15]<-mydata$DecTime.16.[i]
  DecTimeCM[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeCM[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeCM[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeCM[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeCM[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeCM[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeCM[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeCM[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeCM[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeCM)



#DecTimeC is a 1xcontrol vector 
DecTimeCF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1 & mydata$sex[i]==2){
  DecTimeCF[count]<-mydata$DecTime.1.[i]
  DecTimeCF[count+1]<-mydata$DecTime.2.[i]
  DecTimeCF[count+2]<-mydata$DecTime.3.[i]
  DecTimeCF[count+3]<-mydata$DecTime.4.[i]
  DecTimeCF[count+4]<-mydata$DecTime.5.[i]
  DecTimeCF[count+5]<-mydata$DecTime.6.[i]
  DecTimeCF[count+6]<-mydata$DecTime.7.[i]
  DecTimeCF[count+7]<-mydata$DecTime.8.[i]
  DecTimeCF[count+8]<-mydata$DecTime.9.[i]
  DecTimeCF[count+9]<-mydata$DecTime.10.[i]
  DecTimeCF[count+10]<-mydata$DecTime.11.[i]
  DecTimeCF[count+11]<-mydata$DecTime.12.[i]
  DecTimeCF[count+12]<-mydata$DecTime.13.[i]
  DecTimeCF[count+13]<-mydata$DecTime.14.[i]
  DecTimeCF[count+14]<-mydata$DecTime.15.[i]
  DecTimeCF[count+15]<-mydata$DecTime.16.[i]
  DecTimeCF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeCF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeCF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeCF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeCF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeCF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeCF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeCF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeCF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeCF)

######


#DecTimeF is a 1xcontrol vector 
DecTimeF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  DecTimeF[count]<-mydata$DecTime.1.[i]
  DecTimeF[count+1]<-mydata$DecTime.2.[i]
  DecTimeF[count+2]<-mydata$DecTime.3.[i]
  DecTimeF[count+3]<-mydata$DecTime.4.[i]
  DecTimeF[count+4]<-mydata$DecTime.5.[i]
  DecTimeF[count+5]<-mydata$DecTime.6.[i]
  DecTimeF[count+6]<-mydata$DecTime.7.[i]
  DecTimeF[count+7]<-mydata$DecTime.8.[i]
  DecTimeF[count+8]<-mydata$DecTime.9.[i]
  DecTimeF[count+9]<-mydata$DecTime.10.[i]
  DecTimeF[count+10]<-mydata$DecTime.11.[i]
  DecTimeF[count+11]<-mydata$DecTime.12.[i]
  DecTimeF[count+12]<-mydata$DecTime.13.[i]
  DecTimeF[count+13]<-mydata$DecTime.14.[i]
  DecTimeF[count+14]<-mydata$DecTime.15.[i]
  DecTimeF[count+15]<-mydata$DecTime.16.[i]
  DecTimeF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
table(DecTimeF)
mean(DecTimeF)

#DecTimeF is a 1xcontrol vector 
DecTimeFM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==1){
  DecTimeFM[count]<-mydata$DecTime.1.[i]
  DecTimeFM[count+1]<-mydata$DecTime.2.[i]
  DecTimeFM[count+2]<-mydata$DecTime.3.[i]
  DecTimeFM[count+3]<-mydata$DecTime.4.[i]
  DecTimeFM[count+4]<-mydata$DecTime.5.[i]
  DecTimeFM[count+5]<-mydata$DecTime.6.[i]
  DecTimeFM[count+6]<-mydata$DecTime.7.[i]
  DecTimeFM[count+7]<-mydata$DecTime.8.[i]
  DecTimeFM[count+8]<-mydata$DecTime.9.[i]
  DecTimeFM[count+9]<-mydata$DecTime.10.[i]
  DecTimeFM[count+10]<-mydata$DecTime.11.[i]
  DecTimeFM[count+11]<-mydata$DecTime.12.[i]
  DecTimeFM[count+12]<-mydata$DecTime.13.[i]
  DecTimeFM[count+13]<-mydata$DecTime.14.[i]
  DecTimeFM[count+14]<-mydata$DecTime.15.[i]
  DecTimeFM[count+15]<-mydata$DecTime.16.[i]
  DecTimeFM[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeFM[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeFM[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeFM[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeFM[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeFM[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeFM[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeFM[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeFM[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeFM)



#DecTimeC is a 1xcontrol vector 
DecTimeFF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2 & mydata$sex[i]==2){
  DecTimeFF[count]<-mydata$DecTime.1.[i]
  DecTimeFF[count+1]<-mydata$DecTime.2.[i]
  DecTimeFF[count+2]<-mydata$DecTime.3.[i]
  DecTimeFF[count+3]<-mydata$DecTime.4.[i]
  DecTimeFF[count+4]<-mydata$DecTime.5.[i]
  DecTimeFF[count+5]<-mydata$DecTime.6.[i]
  DecTimeFF[count+6]<-mydata$DecTime.7.[i]
  DecTimeFF[count+7]<-mydata$DecTime.8.[i]
  DecTimeFF[count+8]<-mydata$DecTime.9.[i]
  DecTimeFF[count+9]<-mydata$DecTime.10.[i]
  DecTimeFF[count+10]<-mydata$DecTime.11.[i]
  DecTimeFF[count+11]<-mydata$DecTime.12.[i]
  DecTimeFF[count+12]<-mydata$DecTime.13.[i]
  DecTimeFF[count+13]<-mydata$DecTime.14.[i]
  DecTimeFF[count+14]<-mydata$DecTime.15.[i]
  DecTimeFF[count+15]<-mydata$DecTime.16.[i]
  DecTimeFF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeFF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeFF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeFF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeFF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeFF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeFF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeFF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeFF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeCF)


mean(DecTimeFF)

####




#DecTimeA is a 1xcontrol vector 
DecTimeA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  DecTimeA[count]<-mydata$DecTime.1.[i]
  DecTimeA[count+1]<-mydata$DecTime.2.[i]
  DecTimeA[count+2]<-mydata$DecTime.3.[i]
  DecTimeA[count+3]<-mydata$DecTime.4.[i]
  DecTimeA[count+4]<-mydata$DecTime.5.[i]
  DecTimeA[count+5]<-mydata$DecTime.6.[i]
  DecTimeA[count+6]<-mydata$DecTime.7.[i]
  DecTimeA[count+7]<-mydata$DecTime.8.[i]
  DecTimeA[count+8]<-mydata$DecTime.9.[i]
  DecTimeA[count+9]<-mydata$DecTime.10.[i]
  DecTimeA[count+10]<-mydata$DecTime.11.[i]
  DecTimeA[count+11]<-mydata$DecTime.12.[i]
  DecTimeA[count+12]<-mydata$DecTime.13.[i]
  DecTimeA[count+13]<-mydata$DecTime.14.[i]
  DecTimeA[count+14]<-mydata$DecTime.15.[i]
  DecTimeA[count+15]<-mydata$DecTime.16.[i]
  DecTimeA[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeA[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeA[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeA[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeA[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeA[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeA[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeA[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeA[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
table(DecTimeA)
mean(DecTimeA)

#DecTimeF is a 1xcontrol vector 
DecTimeAM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==1){
  DecTimeAM[count]<-mydata$DecTime.1.[i]
  DecTimeAM[count+1]<-mydata$DecTime.2.[i]
  DecTimeAM[count+2]<-mydata$DecTime.3.[i]
  DecTimeAM[count+3]<-mydata$DecTime.4.[i]
  DecTimeAM[count+4]<-mydata$DecTime.5.[i]
  DecTimeAM[count+5]<-mydata$DecTime.6.[i]
  DecTimeAM[count+6]<-mydata$DecTime.7.[i]
  DecTimeAM[count+7]<-mydata$DecTime.8.[i]
  DecTimeAM[count+8]<-mydata$DecTime.9.[i]
  DecTimeAM[count+9]<-mydata$DecTime.10.[i]
  DecTimeAM[count+10]<-mydata$DecTime.11.[i]
  DecTimeAM[count+11]<-mydata$DecTime.12.[i]
  DecTimeAM[count+12]<-mydata$DecTime.13.[i]
  DecTimeAM[count+13]<-mydata$DecTime.14.[i]
  DecTimeAM[count+14]<-mydata$DecTime.15.[i]
  DecTimeAM[count+15]<-mydata$DecTime.16.[i]
  DecTimeAM[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeAM[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeAM[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeAM[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeAM[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeAM[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeAM[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeAM[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeAM[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeAM)



#DecTimeC is a 1xcontrol vector 
DecTimeAF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3 & mydata$sex[i]==2){
  DecTimeAF[count]<-mydata$DecTime.1.[i]
  DecTimeAF[count+1]<-mydata$DecTime.2.[i]
  DecTimeAF[count+2]<-mydata$DecTime.3.[i]
  DecTimeAF[count+3]<-mydata$DecTime.4.[i]
  DecTimeAF[count+4]<-mydata$DecTime.5.[i]
  DecTimeAF[count+5]<-mydata$DecTime.6.[i]
  DecTimeAF[count+6]<-mydata$DecTime.7.[i]
  DecTimeAF[count+7]<-mydata$DecTime.8.[i]
  DecTimeAF[count+8]<-mydata$DecTime.9.[i]
  DecTimeAF[count+9]<-mydata$DecTime.10.[i]
  DecTimeAF[count+10]<-mydata$DecTime.11.[i]
  DecTimeAF[count+11]<-mydata$DecTime.12.[i]
  DecTimeAF[count+12]<-mydata$DecTime.13.[i]
  DecTimeAF[count+13]<-mydata$DecTime.14.[i]
  DecTimeAF[count+14]<-mydata$DecTime.15.[i]
  DecTimeAF[count+15]<-mydata$DecTime.16.[i]
  DecTimeAF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeAF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeAF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeAF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeAF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeAF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeAF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeAF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeAF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeCF)


mean(DecTimeAF)



#####

#DecTimeP is a 1xcontrol vector 
DecTimeP<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  DecTimeP[count]<-mydata$DecTime.1.[i]
  DecTimeP[count+1]<-mydata$DecTime.2.[i]
  DecTimeP[count+2]<-mydata$DecTime.3.[i]
  DecTimeP[count+3]<-mydata$DecTime.4.[i]
  DecTimeP[count+4]<-mydata$DecTime.5.[i]
  DecTimeP[count+5]<-mydata$DecTime.6.[i]
  DecTimeP[count+6]<-mydata$DecTime.7.[i]
  DecTimeP[count+7]<-mydata$DecTime.8.[i]
  DecTimeP[count+8]<-mydata$DecTime.9.[i]
  DecTimeP[count+9]<-mydata$DecTime.10.[i]
  DecTimeP[count+10]<-mydata$DecTime.11.[i]
  DecTimeP[count+11]<-mydata$DecTime.12.[i]
  DecTimeP[count+12]<-mydata$DecTime.13.[i]
  DecTimeP[count+13]<-mydata$DecTime.14.[i]
  DecTimeP[count+14]<-mydata$DecTime.15.[i]
  DecTimeP[count+15]<-mydata$DecTime.16.[i]
  DecTimeP[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimeP[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimeP[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimeP[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimeP[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimeP[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimeP[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimeP[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimeP[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
table(DecTimeP)
mean(DecTimeP)

#DecTimeF is a 1xcontrol vector 
DecTimePM<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==1){
  DecTimePM[count]<-mydata$DecTime.1.[i]
  DecTimePM[count+1]<-mydata$DecTime.2.[i]
  DecTimePM[count+2]<-mydata$DecTime.3.[i]
  DecTimePM[count+3]<-mydata$DecTime.4.[i]
  DecTimePM[count+4]<-mydata$DecTime.5.[i]
  DecTimePM[count+5]<-mydata$DecTime.6.[i]
  DecTimePM[count+6]<-mydata$DecTime.7.[i]
  DecTimePM[count+7]<-mydata$DecTime.8.[i]
  DecTimePM[count+8]<-mydata$DecTime.9.[i]
  DecTimePM[count+9]<-mydata$DecTime.10.[i]
  DecTimePM[count+10]<-mydata$DecTime.11.[i]
  DecTimePM[count+11]<-mydata$DecTime.12.[i]
  DecTimePM[count+12]<-mydata$DecTime.13.[i]
  DecTimePM[count+13]<-mydata$DecTime.14.[i]
  DecTimePM[count+14]<-mydata$DecTime.15.[i]
  DecTimePM[count+15]<-mydata$DecTime.16.[i]
  DecTimePM[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimePM[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimePM[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimePM[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimePM[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimePM[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimePM[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimePM[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimePM[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimePM)



#DecTimeC is a 1xcontrol vector 
DecTimePF<-numeric(50)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4 & mydata$sex[i]==2){
  DecTimePF[count]<-mydata$DecTime.1.[i]
  DecTimePF[count+1]<-mydata$DecTime.2.[i]
  DecTimePF[count+2]<-mydata$DecTime.3.[i]
  DecTimePF[count+3]<-mydata$DecTime.4.[i]
  DecTimePF[count+4]<-mydata$DecTime.5.[i]
  DecTimePF[count+5]<-mydata$DecTime.6.[i]
  DecTimePF[count+6]<-mydata$DecTime.7.[i]
  DecTimePF[count+7]<-mydata$DecTime.8.[i]
  DecTimePF[count+8]<-mydata$DecTime.9.[i]
  DecTimePF[count+9]<-mydata$DecTime.10.[i]
  DecTimePF[count+10]<-mydata$DecTime.11.[i]
  DecTimePF[count+11]<-mydata$DecTime.12.[i]
  DecTimePF[count+12]<-mydata$DecTime.13.[i]
  DecTimePF[count+13]<-mydata$DecTime.14.[i]
  DecTimePF[count+14]<-mydata$DecTime.15.[i]
  DecTimePF[count+15]<-mydata$DecTime.16.[i]
  DecTimePF[count+16]<-mydata$DecTime.17.[i]
  jump<-17
  if(is.na(mydata$DecTime.18.[i])==FALSE){DecTimePF[count+17]<-mydata$DecTime.18.[i]
  jump<-18}
  if(is.na(mydata$DecTime.19.[i])==FALSE){DecTimePF[count+18]<-mydata$DecTime.19.[i]
  jump<-19}
  if(is.na(mydata$DecTime.20.[i])==FALSE){DecTimePF[count+19]<-mydata$DecTime.20.[i]
  jump<-20}
  if(is.na(mydata$DecTime.21.[i])==FALSE){DecTimePF[count+20]<-mydata$DecTime.21.[i]
  jump<-21}
  if(is.na(mydata$DecTime.22.[i])==FALSE){DecTimePF[count+21]<-mydata$DecTime.22.[i]
  jump<-22}
  if(is.na(mydata$DecTime.23.[i])==FALSE){DecTimePF[count+22]<-mydata$DecTime.23.[i]
  jump<-23}
  if(is.na(mydata$DecTime.24.[i])==FALSE){DecTimePF[count+23]<-mydata$DecTime.24.[i]
  jump<-24}
  if(is.na(mydata$DecTime.25.[i])==FALSE){DecTimePF[count+24]<-mydata$DecTime.25.[i]
  jump<-25}
  count<-count+jump
}
}
mean(DecTimeCF)


mean(DecTimePF)



#####


#GENDER AND DECISION TIME

t.test(DecTimeC,DecTimeF)
t.test(DecTimeC,DecTimeA)
t.test(DecTimeC,DecTimeP)

t.test(DecTimeCM,DecTimeFM)
t.test(DecTimeCM,DecTimeAM)
t.test(DecTimeCM,DecTimePM)

t.test(DecTimeCF,DecTimeFF)
t.test(DecTimeCF,DecTimeAF)
t.test(DecTimeCF,DecTimePF)

t.test(DecTimeCF,DecTimeCM)
t.test(DecTimeFF,DecTimeFM)
t.test(DecTimeAF,DecTimeAM)
t.test(DecTimePF,DecTimePM)
####



# Behavior after punishment after fine received










#FastBelief is a 1x6749 vector 
FastBelief<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  FastBelief[count]<-mydata$GuessFast.1.[i]
  FastBelief[count+1]<-mydata$GuessFast.2.[i]
  FastBelief[count+2]<-mydata$GuessFast.3.[i]
  FastBelief[count+3]<-mydata$GuessFast.4.[i]
  FastBelief[count+4]<-mydata$GuessFast.5.[i]
  FastBelief[count+5]<-mydata$GuessFast.6.[i]
  FastBelief[count+6]<-mydata$GuessFast.7.[i]
  FastBelief[count+7]<-mydata$GuessFast.8.[i]
  FastBelief[count+8]<-mydata$GuessFast.9.[i]
  FastBelief[count+9]<-mydata$GuessFast.10.[i]
  FastBelief[count+10]<-mydata$GuessFast.11.[i]
  FastBelief[count+11]<-mydata$GuessFast.12.[i]
  FastBelief[count+12]<-mydata$GuessFast.13.[i]
  FastBelief[count+13]<-mydata$GuessFast.14.[i]
  FastBelief[count+14]<-mydata$GuessFast.15.[i]
  FastBelief[count+15]<-mydata$GuessFast.16.[i]
  FastBelief[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBelief[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBelief[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBelief[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBelief[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBelief[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBelief[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBelief[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBelief[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
tail(FastBelief, 46)
table(FastBelief)

#SlowBelief is a 1x6749 vector 
SlowBelief<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  SlowBelief[count]<-mydata$GuessSlow.1.[i]
  SlowBelief[count+1]<-mydata$GuessSlow.2.[i]
  SlowBelief[count+2]<-mydata$GuessSlow.3.[i]
  SlowBelief[count+3]<-mydata$GuessSlow.4.[i]
  SlowBelief[count+4]<-mydata$GuessSlow.5.[i]
  SlowBelief[count+5]<-mydata$GuessSlow.6.[i]
  SlowBelief[count+6]<-mydata$GuessSlow.7.[i]
  SlowBelief[count+7]<-mydata$GuessSlow.8.[i]
  SlowBelief[count+8]<-mydata$GuessSlow.9.[i]
  SlowBelief[count+9]<-mydata$GuessSlow.10.[i]
  SlowBelief[count+10]<-mydata$GuessSlow.11.[i]
  SlowBelief[count+11]<-mydata$GuessSlow.12.[i]
  SlowBelief[count+12]<-mydata$GuessSlow.13.[i]
  SlowBelief[count+13]<-mydata$GuessSlow.14.[i]
  SlowBelief[count+14]<-mydata$GuessSlow.15.[i]
  SlowBelief[count+15]<-mydata$GuessSlow.16.[i]
  SlowBelief[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBelief[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBelief[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBelief[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBelief[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBelief[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBelief[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBelief[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBelief[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
head(SlowBelief, 500)
table(SlowBelief)

hist(AutoBelief)

#AutoBelief is a 1x6749 vector 
AutoBelief<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  AutoBelief[count]<-mydata$GuessAuto.1.[i]
  AutoBelief[count+1]<-mydata$GuessAuto.2.[i]
  AutoBelief[count+2]<-mydata$GuessAuto.3.[i]
  AutoBelief[count+3]<-mydata$GuessAuto.4.[i]
  AutoBelief[count+4]<-mydata$GuessAuto.5.[i]
  AutoBelief[count+5]<-mydata$GuessAuto.6.[i]
  AutoBelief[count+6]<-mydata$GuessAuto.7.[i]
  AutoBelief[count+7]<-mydata$GuessAuto.8.[i]
  AutoBelief[count+8]<-mydata$GuessAuto.9.[i]
  AutoBelief[count+9]<-mydata$GuessAuto.10.[i]
  AutoBelief[count+10]<-mydata$GuessAuto.11.[i]
  AutoBelief[count+11]<-mydata$GuessAuto.12.[i]
  AutoBelief[count+12]<-mydata$GuessAuto.13.[i]
  AutoBelief[count+13]<-mydata$GuessAuto.14.[i]
  AutoBelief[count+14]<-mydata$GuessAuto.15.[i]
  AutoBelief[count+15]<-mydata$GuessAuto.16.[i]
  AutoBelief[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBelief[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBelief[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBelief[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBelief[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBelief[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBelief[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBelief[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBelief[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
tail(AutoBelief, 46)
table(AutoBelief)

#PrevAcc is a 1x6749 vector 
PrevAcc<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PrevAcc[count]<-0
  PrevAcc[count+1]<-mydata$AccidentHistory.1.[i]
  PrevAcc[count+2]<-mydata$AccidentHistory.2.[i]
  PrevAcc[count+3]<-mydata$AccidentHistory.3.[i]
  PrevAcc[count+4]<-mydata$AccidentHistory.4.[i]
  PrevAcc[count+5]<-mydata$AccidentHistory.5.[i]
  PrevAcc[count+6]<-mydata$AccidentHistory.6.[i]
  PrevAcc[count+7]<-mydata$AccidentHistory.7.[i]
  PrevAcc[count+8]<-mydata$AccidentHistory.8.[i]
  PrevAcc[count+9]<-mydata$AccidentHistory.9.[i]
  PrevAcc[count+10]<-mydata$AccidentHistory.10.[i]
  PrevAcc[count+11]<-mydata$AccidentHistory.11.[i]
  PrevAcc[count+12]<-mydata$AccidentHistory.12.[i]
  PrevAcc[count+13]<-mydata$AccidentHistory.13.[i]
  PrevAcc[count+14]<-mydata$AccidentHistory.14.[i]
  PrevAcc[count+15]<-mydata$AccidentHistory.15.[i]
  PrevAcc[count+16]<-mydata$AccidentHistory.16.[i]
  jump<-16
  if(is.na(mydata$AccidentHistory.17.[i])==FALSE){PrevAcc[count+17]<-mydata$AccidentHistory.17.[i]
  jump<-17}
  if(is.na(mydata$AccidentHistory.18.[i])==FALSE){PrevAcc[count+18]<-mydata$AccidentHistory.18.[i]
  jump<-18}
  if(is.na(mydata$AccidentHistory.19.[i])==FALSE){PrevAcc[count+19]<-mydata$AccidentHistory.19.[i]
  jump<-19}
  if(is.na(mydata$AccidentHistory.20.[i])==FALSE){PrevAcc[count+20]<-mydata$AccidentHistory.20.[i]
  jump<-20}
  if(is.na(mydata$AccidentHistory.21.[i])==FALSE){PrevAcc[count+21]<-mydata$AccidentHistory.21.[i]
  jump<-21}
  if(is.na(mydata$AccidentHistory.22.[i])==FALSE){PrevAcc[count+22]<-mydata$AccidentHistory.22.[i]
  jump<-22}
  if(is.na(mydata$AccidentHistory.23.[i])==FALSE){PrevAcc[count+23]<-mydata$AccidentHistory.23.[i]
  jump<-23}
  if(is.na(mydata$AccidentHistory.24.[i])==FALSE){PrevAcc[count+24]<-mydata$AccidentHistory.24.[i]
  jump<-24}
  if(is.na(mydata$AccidentHistory.25.[i])==FALSE){PrevAcc[count+25]<-mydata$AccidentHistory.25.[i]
  jump<-25}
  count<-count+jump
}
PrevAcc<-c(PrevAcc[1:6749])
tail(PrevAcc, 38)
table(PrevAcc)

#PrevEarn is a 1x6749 vector 
PrevEarn<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PrevEarn[count]<-0
  PrevEarn[count+1]<-mydata$ChoicePayoff.1.[i]
  PrevEarn[count+2]<-mydata$ChoicePayoff.2.[i]
  PrevEarn[count+3]<-mydata$ChoicePayoff.3.[i]
  PrevEarn[count+4]<-mydata$ChoicePayoff.4.[i]
  PrevEarn[count+5]<-mydata$ChoicePayoff.5.[i]
  PrevEarn[count+6]<-mydata$ChoicePayoff.6.[i]
  PrevEarn[count+7]<-mydata$ChoicePayoff.7.[i]
  PrevEarn[count+8]<-mydata$ChoicePayoff.8.[i]
  PrevEarn[count+9]<-mydata$ChoicePayoff.9.[i]
  PrevEarn[count+10]<-mydata$ChoicePayoff.10.[i]
  PrevEarn[count+11]<-mydata$ChoicePayoff.11.[i]
  PrevEarn[count+12]<-mydata$ChoicePayoff.12.[i]
  PrevEarn[count+13]<-mydata$ChoicePayoff.13.[i]
  PrevEarn[count+14]<-mydata$ChoicePayoff.14.[i]
  PrevEarn[count+15]<-mydata$ChoicePayoff.15.[i]
  PrevEarn[count+16]<-mydata$ChoicePayoff.16.[i]
  jump<-16
  if(is.na(mydata$ChoicePayoff.17.[i])==FALSE){PrevEarn[count+17]<-mydata$ChoicePayoff.17.[i]
  jump<-17}
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){PrevEarn[count+18]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){PrevEarn[count+19]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){PrevEarn[count+20]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){PrevEarn[count+21]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){PrevEarn[count+22]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){PrevEarn[count+23]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){PrevEarn[count+24]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){PrevEarn[count+25]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}
PrevEarn<-c(PrevEarn[1:6749])
tail(PrevEarn, 38)
table(PrevEarn)



#Earn is a 1x6749 vector 
Earn<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  Earn[count]<-mydata$ChoicePayoff.1.[i]
  Earn[count+1]<-mydata$ChoicePayoff.2.[i]
  Earn[count+2]<-mydata$ChoicePayoff.3.[i]
  Earn[count+3]<-mydata$ChoicePayoff.4.[i]
  Earn[count+4]<-mydata$ChoicePayoff.5.[i]
  Earn[count+5]<-mydata$ChoicePayoff.6.[i]
  Earn[count+6]<-mydata$ChoicePayoff.7.[i]
  Earn[count+7]<-mydata$ChoicePayoff.8.[i]
  Earn[count+8]<-mydata$ChoicePayoff.9.[i]
  Earn[count+9]<-mydata$ChoicePayoff.10.[i]
  Earn[count+10]<-mydata$ChoicePayoff.11.[i]
  Earn[count+11]<-mydata$ChoicePayoff.12.[i]
  Earn[count+12]<-mydata$ChoicePayoff.13.[i]
  Earn[count+13]<-mydata$ChoicePayoff.14.[i]
  Earn[count+14]<-mydata$ChoicePayoff.15.[i]
  Earn[count+15]<-mydata$ChoicePayoff.16.[i]
  Earn[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){Earn[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){Earn[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){Earn[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){Earn[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){Earn[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){Earn[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){Earn[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){Earn[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
#  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){Earn[count+25]<-mydata$ChoicePayoff.25.[i]
#  jump<-25}
  count<-count+jump
}
Earn<-c(Earn[1:6749])
tail(Earn, 38)
table(Earn)


#AdjEarn is a 1x6749 vector 
AdjEarn<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  AdjEarn[count]<-mydata$AdjChoicePayoff.1.[i]
  AdjEarn[count+1]<-mydata$AdjChoicePayoff.2.[i]
  AdjEarn[count+2]<-mydata$AdjChoicePayoff.3.[i]
  AdjEarn[count+3]<-mydata$AdjChoicePayoff.4.[i]
  AdjEarn[count+4]<-mydata$AdjChoicePayoff.5.[i]
  AdjEarn[count+5]<-mydata$AdjChoicePayoff.6.[i]
  AdjEarn[count+6]<-mydata$AdjChoicePayoff.7.[i]
  AdjEarn[count+7]<-mydata$AdjChoicePayoff.8.[i]
  AdjEarn[count+8]<-mydata$AdjChoicePayoff.9.[i]
  AdjEarn[count+9]<-mydata$AdjChoicePayoff.10.[i]
  AdjEarn[count+10]<-mydata$AdjChoicePayoff.11.[i]
  AdjEarn[count+11]<-mydata$AdjChoicePayoff.12.[i]
  AdjEarn[count+12]<-mydata$AdjChoicePayoff.13.[i]
  AdjEarn[count+13]<-mydata$AdjChoicePayoff.14.[i]
  AdjEarn[count+14]<-mydata$AdjChoicePayoff.15.[i]
  AdjEarn[count+15]<-mydata$AdjChoicePayoff.16.[i]
  AdjEarn[count+16]<-mydata$AdjChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$AdjChoicePayoff.18.[i])==FALSE){AdjEarn[count+17]<-mydata$AdjChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$AdjChoicePayoff.19.[i])==FALSE){AdjEarn[count+18]<-mydata$AdjChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$AdjChoicePayoff.20.[i])==FALSE){AdjEarn[count+19]<-mydata$AdjChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$AdjChoicePayoff.21.[i])==FALSE){AdjEarn[count+20]<-mydata$AdjChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$AdjChoicePayoff.22.[i])==FALSE){AdjEarn[count+21]<-mydata$AdjChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$AdjChoicePayoff.23.[i])==FALSE){AdjEarn[count+22]<-mydata$AdjChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$AdjChoicePayoff.24.[i])==FALSE){AdjEarn[count+23]<-mydata$AdjChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$AdjChoicePayoff.25.[i])==FALSE){AdjEarn[count+24]<-mydata$AdjChoicePayoff.25.[i]
  jump<-25}
  #  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){AdjEarn[count+25]<-mydata$ChoicePayoff.25.[i]
  #  jump<-25}
  count<-count+jump
}
AdjEarn<-c(AdjEarn[1:6749])
tail(AdjEarn, 38)
table(AdjEarn)



#PrevChoice is a 1x6749 vector 
PrevChoice<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PrevChoice[count]<-0
  PrevChoice[count+1]<-mydata$DrivingChoice.1.[i]
  PrevChoice[count+2]<-mydata$DrivingChoice.2.[i]
  PrevChoice[count+3]<-mydata$DrivingChoice.3.[i]
  PrevChoice[count+4]<-mydata$DrivingChoice.4.[i]
  PrevChoice[count+5]<-mydata$DrivingChoice.5.[i]
  PrevChoice[count+6]<-mydata$DrivingChoice.6.[i]
  PrevChoice[count+7]<-mydata$DrivingChoice.7.[i]
  PrevChoice[count+8]<-mydata$DrivingChoice.8.[i]
  PrevChoice[count+9]<-mydata$DrivingChoice.9.[i]
  PrevChoice[count+10]<-mydata$DrivingChoice.10.[i]
  PrevChoice[count+11]<-mydata$DrivingChoice.11.[i]
  PrevChoice[count+12]<-mydata$DrivingChoice.12.[i]
  PrevChoice[count+13]<-mydata$DrivingChoice.13.[i]
  PrevChoice[count+14]<-mydata$DrivingChoice.14.[i]
  PrevChoice[count+15]<-mydata$DrivingChoice.15.[i]
  PrevChoice[count+16]<-mydata$DrivingChoice.16.[i]
  jump<-16
  if(is.na(mydata$DrivingChoice.17.[i])==FALSE){PrevChoice[count+17]<-mydata$DrivingChoice.17.[i]
  jump<-17}
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){PrevChoice[count+18]<-mydata$DrivingChoice.18.[i]
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){PrevChoice[count+19]<-mydata$DrivingChoice.19.[i]
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){PrevChoice[count+20]<-mydata$DrivingChoice.20.[i]
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){PrevChoice[count+21]<-mydata$DrivingChoice.21.[i]
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){PrevChoice[count+22]<-mydata$DrivingChoice.22.[i]
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){PrevChoice[count+23]<-mydata$DrivingChoice.23.[i]
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){PrevChoice[count+24]<-mydata$DrivingChoice.24.[i]
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){PrevChoice[count+25]<-mydata$DrivingChoice.25.[i]
  jump<-25}
  count<-count+jump
}
PrevChoice<-c(PrevChoice[1:6749])
tail(PrevChoice, 38)
table(PrevChoice)


#PrevFast is a 1x6749 vector 
PrevFast<-numeric(NumObsTotal)
for(i in 1:NumObsTotal){
if(PrevChoice[i]==3){PrevFast[i]<-1}
}
table(PrevFast)

#DOESNT WORK



#PrevSlow is a 1x6749 vector 
PrevSlow<-numeric(NumObsTotal)
for(i in 1:NumObsTotal){
  if(PrevChoice[i]==2){PrevSlow[i]<-1}
}
table(PrevSlow)

#PrevAuto is a 1x6749 vector 
PrevAuto<-numeric(NumObsTotal)
for(i in 1:NumObsTotal){
  if(PrevChoice[i]==1){PrevAuto[i]<-1}
}
table(PrevAuto)


#PrevSpeed is a 1x6749 vector 
PrevSpeed<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PrevSpeed[count]<-0
  PrevSpeed[count+1]<-mydata$AvgSpeed.1.[i]
  PrevSpeed[count+2]<-mydata$AvgSpeed.2.[i]
  PrevSpeed[count+3]<-mydata$AvgSpeed.3.[i]
  PrevSpeed[count+4]<-mydata$AvgSpeed.4.[i]
  PrevSpeed[count+5]<-mydata$AvgSpeed.5.[i]
  PrevSpeed[count+6]<-mydata$AvgSpeed.6.[i]
  PrevSpeed[count+7]<-mydata$AvgSpeed.7.[i]
  PrevSpeed[count+8]<-mydata$AvgSpeed.8.[i]
  PrevSpeed[count+9]<-mydata$AvgSpeed.9.[i]
  PrevSpeed[count+10]<-mydata$AvgSpeed.10.[i]
  PrevSpeed[count+11]<-mydata$AvgSpeed.11.[i]
  PrevSpeed[count+12]<-mydata$AvgSpeed.12.[i]
  PrevSpeed[count+13]<-mydata$AvgSpeed.13.[i]
  PrevSpeed[count+14]<-mydata$AvgSpeed.14.[i]
  PrevSpeed[count+15]<-mydata$AvgSpeed.15.[i]
  PrevSpeed[count+16]<-mydata$AvgSpeed.16.[i]
  jump<-16
  if(is.na(mydata$AvgSpeed.17.[i])==FALSE){PrevSpeed[count+17]<-mydata$AvgSpeed.17.[i]
  jump<-17}
  if(is.na(mydata$AvgSpeed.18.[i])==FALSE){PrevSpeed[count+18]<-mydata$AvgSpeed.18.[i]
  jump<-18}
  if(is.na(mydata$AvgSpeed.19.[i])==FALSE){PrevSpeed[count+19]<-mydata$AvgSpeed.19.[i]
  jump<-19}
  if(is.na(mydata$AvgSpeed.20.[i])==FALSE){PrevSpeed[count+20]<-mydata$AvgSpeed.20.[i]
  jump<-20}
  if(is.na(mydata$AvgSpeed.21.[i])==FALSE){PrevSpeed[count+21]<-mydata$AvgSpeed.21.[i]
  jump<-21}
  if(is.na(mydata$AvgSpeed.22.[i])==FALSE){PrevSpeed[count+22]<-mydata$AvgSpeed.22.[i]
  jump<-22}
  if(is.na(mydata$AvgSpeed.23.[i])==FALSE){PrevSpeed[count+23]<-mydata$AvgSpeed.23.[i]
  jump<-23}
  if(is.na(mydata$AvgSpeed.24.[i])==FALSE){PrevSpeed[count+24]<-mydata$AvgSpeed.24.[i]
  jump<-24}
  if(is.na(mydata$AvgSpeed.25.[i])==FALSE){PrevSpeed[count+25]<-mydata$AvgSpeed.25.[i]
  jump<-25}
  count<-count+jump
}
PrevSpeed<-c(PrevSpeed[1:6749])
tail(PrevSpeed, 38)
table(PrevSpeed)
#Not working yet...

#PrevGuessAcc is a 1x6749 vector 
PrevGuessAcc<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  PrevGuessAcc[count]<-0
  PrevGuessAcc[count+1]<-mydata$GuessPayoff.1.[i]
  PrevGuessAcc[count+2]<-mydata$GuessPayoff.2.[i]
  PrevGuessAcc[count+3]<-mydata$GuessPayoff.3.[i]
  PrevGuessAcc[count+4]<-mydata$GuessPayoff.4.[i]
  PrevGuessAcc[count+5]<-mydata$GuessPayoff.5.[i]
  PrevGuessAcc[count+6]<-mydata$GuessPayoff.6.[i]
  PrevGuessAcc[count+7]<-mydata$GuessPayoff.7.[i]
  PrevGuessAcc[count+8]<-mydata$GuessPayoff.8.[i]
  PrevGuessAcc[count+9]<-mydata$GuessPayoff.9.[i]
  PrevGuessAcc[count+10]<-mydata$GuessPayoff.10.[i]
  PrevGuessAcc[count+11]<-mydata$GuessPayoff.11.[i]
  PrevGuessAcc[count+12]<-mydata$GuessPayoff.12.[i]
  PrevGuessAcc[count+13]<-mydata$GuessPayoff.13.[i]
  PrevGuessAcc[count+14]<-mydata$GuessPayoff.14.[i]
  PrevGuessAcc[count+15]<-mydata$GuessPayoff.15.[i]
  PrevGuessAcc[count+16]<-mydata$GuessPayoff.16.[i]
  jump<-16
  if(is.na(mydata$GuessPayoff.17.[i])==FALSE){PrevGuessAcc[count+17]<-mydata$GuessPayoff.17.[i]
  jump<-17}
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){PrevGuessAcc[count+18]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){PrevGuessAcc[count+19]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){PrevGuessAcc[count+20]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){PrevGuessAcc[count+21]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){PrevGuessAcc[count+22]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){PrevGuessAcc[count+23]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){PrevGuessAcc[count+24]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){PrevGuessAcc[count+25]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
PrevGuessAcc<-c(PrevGuessAcc[1:6749])
tail(PrevGuessAcc, 38)
table(PrevGuessAcc)

#GuessAcc is a 1x6749 vector 
GuessAcc<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  GuessAcc[count]<-mydata$GuessPayoff.1.[i]
  GuessAcc[count+1]<-mydata$GuessPayoff.2.[i]
  GuessAcc[count+2]<-mydata$GuessPayoff.3.[i]
  GuessAcc[count+3]<-mydata$GuessPayoff.4.[i]
  GuessAcc[count+4]<-mydata$GuessPayoff.5.[i]
  GuessAcc[count+5]<-mydata$GuessPayoff.6.[i]
  GuessAcc[count+6]<-mydata$GuessPayoff.7.[i]
  GuessAcc[count+7]<-mydata$GuessPayoff.8.[i]
  GuessAcc[count+8]<-mydata$GuessPayoff.9.[i]
  GuessAcc[count+9]<-mydata$GuessPayoff.10.[i]
  GuessAcc[count+10]<-mydata$GuessPayoff.11.[i]
  GuessAcc[count+11]<-mydata$GuessPayoff.12.[i]
  GuessAcc[count+12]<-mydata$GuessPayoff.13.[i]
  GuessAcc[count+13]<-mydata$GuessPayoff.14.[i]
  GuessAcc[count+14]<-mydata$GuessPayoff.15.[i]
  GuessAcc[count+15]<-mydata$GuessPayoff.16.[i]
  GuessAcc[count+16]<-mydata$GuessPayoff.17.[i]
  jump<-17
  if(is.na(mydata$GuessPayoff.18.[i])==FALSE){GuessAcc[count+17]<-mydata$GuessPayoff.18.[i]
  jump<-18}
  if(is.na(mydata$GuessPayoff.19.[i])==FALSE){GuessAcc[count+18]<-mydata$GuessPayoff.19.[i]
  jump<-19}
  if(is.na(mydata$GuessPayoff.20.[i])==FALSE){GuessAcc[count+19]<-mydata$GuessPayoff.20.[i]
  jump<-20}
  if(is.na(mydata$GuessPayoff.21.[i])==FALSE){GuessAcc[count+20]<-mydata$GuessPayoff.21.[i]
  jump<-21}
  if(is.na(mydata$GuessPayoff.22.[i])==FALSE){GuessAcc[count+21]<-mydata$GuessPayoff.22.[i]
  jump<-22}
  if(is.na(mydata$GuessPayoff.23.[i])==FALSE){GuessAcc[count+22]<-mydata$GuessPayoff.23.[i]
  jump<-23}
  if(is.na(mydata$GuessPayoff.24.[i])==FALSE){GuessAcc[count+23]<-mydata$GuessPayoff.24.[i]
  jump<-24}
  if(is.na(mydata$GuessPayoff.25.[i])==FALSE){GuessAcc[count+24]<-mydata$GuessPayoff.25.[i]
  jump<-25}
  count<-count+jump
}
tail(GuessAcc, 46)
table(GuessAcc)

#REVISION

#SessCount is a 1x6749 vector
SessCount<-numeric(NumObsTotal)
count<-0
jump<-0
for(i in 1:obs){
  jump<-mydata$totper[i]-1
  for(j in 1:jump){
    SessCount[count+j]<-mydata$SessCount[i]
  }
  count<-count+jump
}


#Sex is a 1x6749 vector
Sex<-numeric(NumObsTotal)
Risk<-numeric(NumObsTotal)
Age<-numeric(NumObsTotal)
StudentType<-numeric(NumObsTotal)
Study<-numeric(NumObsTotal)
Driving<-numeric(NumObsTotal)
Learning<-numeric(NumObsTotal)
Norm<-numeric(NumObsTotal)
SubID<-numeric(NumObsTotal)
count<-0
jump<-0
for(i in 1:obs){
#  if(mydata$ExpType[i]==4){
    jump<-mydata$totper[i]-1
    for(j in 1:jump){
      Sex[count+j]<-mydata$sex[i]
      Risk[count+j]<-mydata$RiskScore[i]
      Age[count+j]<-mydata$age[i]
      StudentType[count+j]<-mydata$student[i]
      Study[count+j]<-mydata$study[i]
      Driving[count+j]<-mydata$Driving[i]
      Learning[count+j]<-mydata$Learning[i]
      Norm[count+j]<-mydata$NormChoice[i]
      SubID[count+j]<-mydata$Subject[i]
      SessCount[count+j]<-mydata$Subject[i]
    }
    count<-count+jump
#  }
}
#turn the 2 values into 0s
for(i in 1:NumObsTotal){
  if(Sex[i]==2){Sex[i]=0}
  if(StudentType[i]==2){StudentType[i]=0}
  if(Driving[i]==2){Driving[i]=3}
  if(Driving[i]==1){Driving[i]=0}
  if(Driving[i]==3){Driving[i]=1}
  if(Learning[i]==2){Learning[i]=0}
}
tail(Risk,19*3+1)

#par(mfrow=c(1,1))

# Beliefs
#Baselines
dataLM<-data.frame(FastBelief,FineDummy,AssocDummy,PunDummy, Sex, Risk,Learning,PrevEarn,Driving, RoundNumLate, PrevAcc)
LMfita<- lm(FastBelief~FineDummy+AssocDummy+PunDummy, data=dataLM)
summary(LMfita)

LMfitb<- lm(SlowBelief~FineDummy+AssocDummy+PunDummy, data=dataLM)
summary(LMfitb)

LMfitc<- lm(AutoBelief~FineDummy+AssocDummy+PunDummy, data=dataLM)
summary(LMfitc)

#Controls
LMfit1<- lm(FastBelief~FineDummy+AssocDummy+PunDummy+Risk + Sex + PrevEarn + PrevAcc+ Learning + Driving + RoundNumLate, data=dataLM)
summary(LMfit1)

LMfit2<- lm(SlowBelief~FineDummy+AssocDummy+PunDummy+Risk + Sex + PrevEarn + PrevAcc + Learning + Driving + RoundNumLate, data=dataLM)
summary(LMfit2)

LMfit3<- lm(AutoBelief~FineDummy+AssocDummy+PunDummy+Risk + Sex + PrevEarn + PrevAcc + Learning + Driving + RoundNumLate, data=dataLM)
summary(LMfit3)

stargazer(LMfita, LMfitb, LMfitc,LMfit1,LMfit2,LMfit3, report=('vc*p'))

PayoffA


### using multinom
#Unused Variables: GuessAcc, Age, Learning, DecTime, PrevGuessAcc,PrevAcc,
data<-data.frame(AutoFastSlow,FineDummy,AssocDummy,PunDummy, FastBelief, SlowBelief,AutoBelief,Sex,DecTime,StudentType, Risk,Learning,PrevEarn,SubID, RoundNumLate,PrevFast, PrevSlow, PrevAuto, SessNum,PrevAcc,PrevEarn, Learning, Driving, SexI, PolicyOrNot,Earn, AdjEarn, SessCount, FastOrNot, PropFemale)
#mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+FastBelief+SlowBelief+AutoBelief+Risk+Sex+DecTime+Driving+StudentType+PrevGuessAcc+PrevAcc, data=data)

table(Earn, SexI)

#Export to stata
library(foreign)
write.dta(data, "P:/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")
          #C:/Users/uctprke/Dropbox/Research/Autonomous_Drivers/Driving_Experiment/Data/Analysis/statadataREV.dta")


#Baseline table
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline", report=('vc*p'))

#Baseline table + Risk
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk", report=('vc*p'))

#Baseline table + Risk + Sex
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk+ Sex", report=('vc*p'))

#Baseline table + Risk + Sex + Age
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age", report=('vc*p'))

#Baseline table + Risk + Sex + Age + PrevEarn
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age+PrevEarn, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round", report=('vc*p'))

#Baseline table + Risk + Sex + Age + PrevEarn + Learning 
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age+PrevEarn +Learning, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round + Learning", report=('vc*p'))


#Baseline table + Risk + Sex + Age + PrevEarn + Learning + Driving
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age+PrevEarn +Learning+ Driving, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round + Learning + Driving", report=('vc*p'))


#Baseline table + Risk + Sex + Age + PrevEarn + Learning + Driving +RoundNumLate
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age+PrevEarn +Learning+ Driving+RoundNumLate+PunDummy*RoundNumLate, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round + Learning + Driving +RoundNumLate", report=('vc*p'))


#Baseline table + Risk + Sex + Age + PrevEarn + Learning + Driving +RoundNumLate
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Risk+Sex+Age+PrevEarn +Learning+ Driving+RoundNumLate, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round + Learning + Driving +RoundNumLate", report=('vc*p'))


#Baseline table  + Sex + Age + PrevEarn + Learning + Driving +RoundNumLate TAKE OUT RISK VARIABLE
mlogitfit<- multinom(AutoFastSlow~FineDummy+AssocDummy+PunDummy+Sex+Age+PrevEarn +Learning+ Driving+RoundNumLate, data=data)
summary(mlogitfit)
z <- summary(mlogitfit)$coefficients/summary(mlogitfit)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p
stargazer(mlogitfit, title="Baseline + Risk + Sex + Age + Earnings in previous round + Learning + Driving +RoundNumLate", report=('vc*p'))


mytable <- table(PrevAccC,AutoFastSlowC) # A will be rows, B will be columns 
mytable # print table 

margin.table(mytable, 1) # A frequencies (summed over B) 
margin.table(mytable, 2) # B frequencies (summed over A)

prop.table(mytable) # cell percentages
prop.table(mytable, 1) # row percentages 
prop.table(mytable, 2) # column percentages

sum(FastOrNotC)/NumObsControl

table(AutoFastSlowC)
table(AutoFastSlowF)
table(AutoFastSlowA)
table(AutoFastSlowP)


prop.table(table(AutoFastSlowC)) # cell percentages
prop.table(table(AutoFastSlowF))
prop.table(table(AutoFastSlowA))
prop.table(table(AutoFastSlowP))


prop.table(mytable, 1) # row percentages 
prop.table(mytable, 2) # column percentages

AccInPun<-562
AccInAssoc<-439
AccInFine<-536
AccControl<-533

AccInControl/NumObsControl
AccInFine/NumObsFine
AccInAssoc/NumObsAssoc
AccInPun/NumObsPun



#Norm Choice
NormChoice

IndNormC<-numeric(80)
IndNormF<-numeric(84)
IndNormA<-numeric(77)
IndNormP<-numeric(85)
IndNormOtherC<-numeric(80)
IndNormOtherF<-numeric(84)
IndNormOtherA<-numeric(77)
IndNormOtherP<-numeric(85)

count<-1
for(i in 1:obs){if(mydata$ExpType[i]==1){
  IndNormC[count]<-mydata$NormChoice[i]
  IndNormOtherC[count]<-mydata$NormChoice2[i]
  count<-count+1
}
  }

count<-1
for(i in 1:obs){if(mydata$ExpType[i]==2){
  IndNormF[count]<-mydata$NormChoice[i]
  IndNormOtherF[count]<-mydata$NormChoice2[i]
  count<-count+1
}
}

count<-1
for(i in 1:obs){if(mydata$ExpType[i]==3){
  IndNormA[count]<-mydata$NormChoice[i]
  IndNormOtherA[count]<-mydata$NormChoice2[i]
  count<-count+1
}
}

count<-1
for(i in 1:obs){if(mydata$ExpType[i]==4){
  IndNormP[count]<-mydata$NormChoice[i]
  IndNormOtherP[count]<-mydata$NormChoice2[i]
  count<-count+1
}
}
table(IndNormOtherC)
table(IndNormOtherF)
table(IndNormOtherA)
table(IndNormOtherP)


#FastOrNotC is a 1x1735 vector
FastOrNotC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  FastOrNotC[count]<-ifelse(mydata$DrivingChoice.1.[i]==3, 1, 0)
  FastOrNotC[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==3, 1, 0)
  FastOrNotC[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==3, 1, 0)
  FastOrNotC[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==3, 1, 0)
  FastOrNotC[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==3, 1, 0)
  FastOrNotC[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==3, 1, 0)
  FastOrNotC[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==3, 1, 0)
  FastOrNotC[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==3, 1, 0)
  FastOrNotC[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==3, 1, 0)
  FastOrNotC[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==3, 1, 0)
  FastOrNotC[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==3, 1, 0)
  FastOrNotC[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==3, 1, 0)
  FastOrNotC[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==3, 1, 0)
  FastOrNotC[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==3, 1, 0)
  FastOrNotC[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==3, 1, 0)
  FastOrNotC[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==3, 1, 0)
  FastOrNotC[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==3, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){FastOrNotC[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==3, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){FastOrNotC[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==3, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){FastOrNotC[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==3, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){FastOrNotC[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==3, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){FastOrNotC[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==3, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){FastOrNotC[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==3, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){FastOrNotC[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==3, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){FastOrNotC[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==3, 1, 0) 
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#FastOrNotC <- FastOrNotC[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(FastOrNotC, 50)
table(FastOrNotC)


#SlowOrNotC is a 1x1735 vector
SlowOrNotC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  SlowOrNotC[count]<-ifelse(mydata$DrivingChoice.1.[i]==2, 1, 0)
  SlowOrNotC[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==2, 1, 0)
  SlowOrNotC[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==2, 1, 0)
  SlowOrNotC[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==2, 1, 0)
  SlowOrNotC[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==2, 1, 0)
  SlowOrNotC[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==2, 1, 0)
  SlowOrNotC[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==2, 1, 0)
  SlowOrNotC[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==2, 1, 0)
  SlowOrNotC[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==2, 1, 0)
  SlowOrNotC[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==2, 1, 0)
  SlowOrNotC[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==2, 1, 0)
  SlowOrNotC[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==2, 1, 0)
  SlowOrNotC[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==2, 1, 0)
  SlowOrNotC[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==2, 1, 0)
  SlowOrNotC[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==2, 1, 0)
  SlowOrNotC[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==2, 1, 0)
  SlowOrNotC[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==2, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){SlowOrNotC[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==2, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){SlowOrNotC[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==2, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){SlowOrNotC[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==2, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){SlowOrNotC[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==2, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){SlowOrNotC[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==2, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){SlowOrNotC[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==2, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){SlowOrNotC[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==2, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){SlowOrNotC[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==2, 1, 0) 
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#SlowOrNotC <- SlowOrNotC[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(SlowOrNotC, 50)
table(SlowOrNotC)

#AutoOrNotC is a 1x1735 vector
AutoOrNotC<-numeric(NumObsControl)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==1){
  AutoOrNotC[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 1, 0)
  AutoOrNotC[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 1, 0)
  AutoOrNotC[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 1, 0)
  AutoOrNotC[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 1, 0)
  AutoOrNotC[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 1, 0)
  AutoOrNotC[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 1, 0)
  AutoOrNotC[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 1, 0)
  AutoOrNotC[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 1, 0)
  AutoOrNotC[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 1, 0)
  AutoOrNotC[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 1, 0)
  AutoOrNotC[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 1, 0)
  AutoOrNotC[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 1, 0)
  AutoOrNotC[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 1, 0)
  AutoOrNotC[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 1, 0)
  AutoOrNotC[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 1, 0)
  AutoOrNotC[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 1, 0)
  AutoOrNotC[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 1, 0)
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoOrNotC[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 1, 0) 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoOrNotC[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 1, 0) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoOrNotC[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 1, 0) 
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoOrNotC[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 1, 0) 
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoOrNotC[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 1, 0) 
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoOrNotC[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 1, 0) 
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoOrNotC[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 1, 0) 
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoOrNotC[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 1, 0) 
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#AutoOrNotC <- AutoOrNotC[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
tail(AutoOrNotC, 50)
table(AutoOrNotC)


FastBeliefCdf<-data.frame(FastOrNotC,FastBeliefC)
newdata <- FastBeliefCdf[ which(FastBeliefC$FastOrNotC==1), ]
hist(newdata$FastBeliefC)


SlowBeliefCdf<-data.frame(SlowOrNotC,SlowBeliefC)
newdata <- SlowBeliefCdf[ which(SlowBeliefC$SlowOrNotC==1), ]
hist(newdata$SlowBeliefC)


AutoBeliefCdf<-data.frame(AutoOrNotC,AutoBeliefC)
newdata <- AutoBeliefCdf[ which(AutoBeliefC$AutoOrNotC==1), ]
hist(newdata$AutoBeliefC)

#Triangle with 3 choices and 3 beliefs
Auto <- AutoBeliefC
Slow <- SlowBeliefC
Fast <- FastBeliefC
#Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
Choice <- AutoFastSlowC
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Choice)
BeliefTriC <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Control') +
  labs(fill = 'Choice') +
  theme_rgbw()#+
  #scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  #theme(legend.position = c(0.82,.8),
    #    legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
 # theme(plot.title = element_text(hjust = 0.5))

#Subset with just the Fast choices
ChoiceFast <- subset(df, Choice == "Fast")
BeliefTriCFast <- ggtern(data = ChoiceFast, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Control') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Slow choices
ChoiceSlow <- subset(df, Choice == "Slow")
BeliefTriCSlow <- ggtern(data = ChoiceSlow, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Control') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Auto choices
ChoiceAuto <- subset(df, Choice == "Auto")
BeliefTriCAuto <- ggtern(data = ChoiceAuto, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Control') +
  labs(fill = 'Choice') +
  theme_rgbw()#+



#3 plots together
grid.arrange(BeliefTriCFast, BeliefTriCSlow,BeliefTriCAuto, ncol=1)


#Moving onto beliefs and choices for the Fine group

#FastBeliefF is a 1x1703 vector 
FastBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  FastBeliefF[count]<-mydata$GuessFast.1.[i]
  FastBeliefF[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefF[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefF[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefF[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefF[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefF[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefF[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefF[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefF[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefF[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefF[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefF[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefF[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefF[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefF[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefF[count+16]<-mydata$GuessFast.17.[i]
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefF[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefF[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefF[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefF[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefF[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefF[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefF[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefF[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#FastBeliefF <- FastBeliefF[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
head(FastBeliefF, 46)
table(FastBeliefF)

#SlowBeliefF is a 1x1703 vector 
SlowBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  SlowBeliefF[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefF[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefF[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefF[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefF[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefF[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefF[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefF[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefF[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefF[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefF[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefF[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefF[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefF[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefF[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefF[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefF[count+16]<-mydata$GuessSlow.17.[i]
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefF[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefF[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefF[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefF[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefF[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefF[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefF[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefF[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#SlowBeliefF <- SlowBeliefF[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(SlowBeliefF, 46)
table(SlowBeliefF)

#AutoBeliefF is a 1x1703 vector 
AutoBeliefF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  AutoBeliefF[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefF[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefF[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefF[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefF[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefF[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefF[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefF[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefF[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefF[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefF[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefF[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefF[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefF[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefF[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefF[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefF[count+16]<-mydata$GuessAuto.17.[i]
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefF[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefF[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefF[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefF[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefF[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefF[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefF[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefF[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#AutoBeliefF <- AutoBeliefF[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(AutoBeliefF, 46)
table(AutoBeliefF)

#AutoFastSlowF is a 1x1703 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowF<-numeric(NumObsFine)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==2){
  AutoFastSlowF[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowF[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowF[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowF[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowF[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowF[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowF[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowF[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowF[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowF[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowF[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowF[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowF[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowF[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowF[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowF[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowF[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowF[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowF[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowF[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowF[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowF[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowF[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowF[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowF[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}

Auto<-c(22,12,NA, 15,19)
Slow<-c(20,8,NA, 25,18)
Fast<-c(58,79,NA, 52,63)
Choice<-c("Male", "Male",NA, "Female", "Female")

test <- data.frame(Auto,Slow,Fast,Choice)
BeliefTriF <- ggtern(data = test, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Change in driving behavior after 1 penalty') +
  labs(fill = 'Choice') + geom_path()+
  theme_rgbw()#+
BeliefTriF

Auto<-c(0.882352941,	0.2,NA, 0.3,	0.5 ,NA,  0.125,	0.333333333 ,NA, 0.666666667,	0.526315789  ,NA,  0,0 ,NA,  0.071428571	,0 ,NA, 0.25,	0.071428571 ,NA,0,0  ,NA,0.142857143,	0.133333333  ,NA, 0.0625,	0 ,NA,0.111111111	,0  ,NA,0,0  ,NA, 0	,0.071428571 ,NA, 0,	0.058823529 ,NA,0,0 ,NA,0,0 ,NA,0,0 ,NA,0,0 ,NA,0,0 ,NA,0,0)
Slow<-c(0.058823529,	0 ,NA,  0.15	,0,NA,0.625,	0.333333333  ,NA, 0,0 ,NA,0,0  ,NA,0.071428571	,0  ,NA,0.25,	0.428571429  ,NA,  0.333333333,	0,NA,0.428571429,	0.666666667  ,NA,.5,.5  ,NA,0.555555556	,0.076923077  ,NA, 0,0 ,NA,0.071428571,	0  ,NA,0.058823529,	0  ,NA,0,0  ,NA,0,0  ,NA,0,0  ,NA,0,0  ,NA,0,0  ,NA,0,0  )
Fast<-c(0.058823529,	0.8,NA, 0.55,	0.5 ,NA,0.25	,0.333333333  ,NA,0.333333333,	0.473684211  ,NA,1,1  ,NA,0.857142857,	1  ,NA, .5,.5 ,NA,0.666666667,	1  ,NA,0.428571429,	0.2  ,NA,0.4375,	0.5  ,NA,0.333333333	,0.923076923  ,NA,1,1  ,NA,0.8	,0.857142857  ,NA,0.8,	0.882352941  ,NA,1,1  ,NA,1,1  ,NA,1,1  ,NA,1,1  ,NA,1,1  ,NA,1,1  )

Choice<-c("Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After")

test <- data.frame(Auto*100,Slow*100,Fast*100,Choice)
BeliefTriF <- ggtern(data = test, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Change in driving behavior after 1 penalty - Males in Fine') +
  labs(fill = 'Choice') + geom_path()+
  theme_rgbw()#+
BeliefTriF


Auto<-c(0.882352941,	0.2,NA, 0.3,	0.5,NA,  0.125,	0.333333333 ,NA, 0.666666667,	0.526315789  ,NA,  0,0 )
Slow<-c(0.058823529,	0 ,NA,  0.15	,0,NA,0.625,	0.333333333  ,NA, 0,0 ,NA,0,0 )
Fast<-c(0.058823529,	0.8,NA, 0.55,	0.5,NA,0.25	,0.333333333  ,NA,0.333333333,	0.473684211  ,NA,1,1  )

Choice<-c("Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After",NA,"Before", "After")

test <- data.frame(Auto*100,Slow*100,Fast*100,Choice)
BeliefTriF <- ggtern(data = test, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Change in driving behavior after 1 penalty - Males in Fine') +
  labs(fill = 'Choice') + geom_path()+
  theme_rgbw()#+
BeliefTriF



#This piece cuts out the 50 0 entries for Session 3 that pop up
#AutoFastSlowF <- AutoFastSlowF[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(AutoFastSlowF, 46)
table(AutoFastSlowF)
#Change numbers to names (optional)
for(i in 1:NumObsFine){ifelse(AutoFastSlowF[i]==1, AutoFastSlowF[i]<-"Fast", ifelse(AutoFastSlowF[i]==2, AutoFastSlowF[i]<-'Slow', AutoFastSlowF[i]<-'Auto'))}

#Triangle with 3 choices and 3 beliefs
Auto <- AutoBeliefF
Slow <- SlowBeliefF
Fast <- FastBeliefF
#Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
Choice <- AutoFastSlowF
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Choice)
BeliefTriF <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Fine') +
  labs(fill = 'Choice') +
  theme_rgbw()#+
#scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
#scale_size_continuous(range = c(2.5, 7.5)) +
#theme(legend.position = c(0.82,.8),
#    legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
# theme(plot.title = element_text(hjust = 0.5))

#Subset with just the Fast choices
ChoiceFast <- subset(df, Choice == "Fast")
BeliefTriCFast <- ggtern(data = ChoiceFast, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Fine') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Slow choices
ChoiceSlow <- subset(df, Choice == "Slow")
BeliefTriCSlow <- ggtern(data = ChoiceSlow, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Fine') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Auto choices
ChoiceAuto <- subset(df, Choice == "Auto")
BeliefTriCAuto <- ggtern(data = ChoiceAuto, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - fine') +
  labs(fill = 'Choice') +
  theme_rgbw()#+


### using multinom
dataF<-data.frame(AutoFastSlowF, FastBeliefF, SlowBeliefF, AutoBeliefF)
mlogitfitF<- multinom(AutoFastSlowF~FastBeliefF+SlowBeliefF+ AutoBeliefF, data=dataF)
#mlogitfitC<- multinom(AutoFastSlowC~FastBeliefC, data=dataC)
summary(mlogitfitF)
z <- summary(mlogitfitF)$coefficients/summary(mlogitfitF)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p



#Moving onto beliefs and choices for the Association group

#FastBeliefA is a 1x1457 vector 
FastBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  FastBeliefA[count]<-mydata$GuessFast.1.[i]
  FastBeliefA[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefA[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefA[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefA[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefA[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefA[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefA[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefA[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefA[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefA[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefA[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefA[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefA[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefA[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefA[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefA[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefA[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefA[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefA[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefA[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefA[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefA[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefA[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefA[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#FastBeliefA <- FastBeliefA[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(FastBeliefA, 46)
table(FastBeliefA)

#SlowBeliefA is a 1x1457 vector 
SlowBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  SlowBeliefA[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefA[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefA[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefA[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefA[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefA[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefA[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefA[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefA[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefA[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefA[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefA[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefA[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefA[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefA[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefA[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefA[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefA[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefA[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefA[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefA[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefA[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefA[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefA[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefA[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#SlowBeliefA <- SlowBeliefA[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(SlowBeliefA, 46)
table(SlowBeliefA)

#AutoBeliefA is a 1x1457 vector 
AutoBeliefA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  AutoBeliefA[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefA[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefA[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefA[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefA[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefA[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefA[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefA[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefA[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefA[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefA[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefA[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefA[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefA[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefA[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefA[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefA[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefA[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefA[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefA[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefA[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefA[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefA[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefA[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefA[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#AutoBeliefA <- AutoBeliefA[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
head(AutoBeliefA, 46)
table(AutoBeliefA)

#AutoFastSlowA is a 1x1457 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowA<-numeric(NumObsAssoc)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==3){
  AutoFastSlowA[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowA[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowA[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowA[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowA[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowA[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowA[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowA[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowA[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowA[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowA[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowA[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowA[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowA[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowA[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowA[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowA[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowA[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowA[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowA[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowA[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowA[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowA[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowA[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowA[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}
head(AutoFastSlowA, 46)
table(AutoFastSlowA)
#Change numbers to names (optional)
for(i in 1:NumObsAssoc){ifelse(AutoFastSlowA[i]==1, AutoFastSlowA[i]<-"Fast", ifelse(AutoFastSlowA[i]==2, AutoFastSlowA[i]<-'Slow', AutoFastSlowA[i]<-'Auto'))}

#Triangle with 3 choices and 3 beliefs
Auto <- AutoBeliefA
Slow <- SlowBeliefA
Fast <- FastBeliefA
#Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
Choice <- AutoFastSlowA
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Choice)
BeliefTriA <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Association') +
  labs(fill = 'Choice') +
  theme_rgbw()#+
#scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
#scale_size_continuous(range = c(2.5, 7.5)) +
#theme(legend.position = c(0.82,.8),
#    legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
# theme(plot.title = element_text(hjust = 0.5))

#Subset with just the Fast choices
ChoiceFast <- subset(df, Choice == "Fast")
BeliefTriAFast <- ggtern(data = ChoiceFast, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Association') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Slow choices
ChoiceSlow <- subset(df, Choice == "Slow")
BeliefTriASlow <- ggtern(data = ChoiceSlow, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Association') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Auto choices
ChoiceAuto <- subset(df, Choice == "Auto")
BeliefTriAAuto <- ggtern(data = ChoiceAuto, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Association') +
  labs(fill = 'Choice') +
  theme_rgbw()#+


### using multinom
dataA<-data.frame(AutoFastSlowA, FastBeliefA, SlowBeliefA, AutoBeliefA)
mlogitfitA<- multinom(AutoFastSlowA~FastBeliefA+SlowBeliefA+ AutoBeliefA, data=dataA)

summary(mlogitfitA)
z <- summary(mlogitfitA)$coefficients/summary(mlogitfitA)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p


#Moving onto beliefs and choices for the Punishment group

#FastBeliefP is a 1x1854 vector 
FastBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  FastBeliefP[count]<-mydata$GuessFast.1.[i]
  FastBeliefP[count+1]<-mydata$GuessFast.2.[i]
  FastBeliefP[count+2]<-mydata$GuessFast.3.[i]
  FastBeliefP[count+3]<-mydata$GuessFast.4.[i]
  FastBeliefP[count+4]<-mydata$GuessFast.5.[i]
  FastBeliefP[count+5]<-mydata$GuessFast.6.[i]
  FastBeliefP[count+6]<-mydata$GuessFast.7.[i]
  FastBeliefP[count+7]<-mydata$GuessFast.8.[i]
  FastBeliefP[count+8]<-mydata$GuessFast.9.[i]
  FastBeliefP[count+9]<-mydata$GuessFast.10.[i]
  FastBeliefP[count+10]<-mydata$GuessFast.11.[i]
  FastBeliefP[count+11]<-mydata$GuessFast.12.[i]
  FastBeliefP[count+12]<-mydata$GuessFast.13.[i]
  FastBeliefP[count+13]<-mydata$GuessFast.14.[i]
  FastBeliefP[count+14]<-mydata$GuessFast.15.[i]
  FastBeliefP[count+15]<-mydata$GuessFast.16.[i]
  FastBeliefP[count+16]<-mydata$GuessFast.17.[i]
  jump<-17
  if(is.na(mydata$GuessFast.18.[i])==FALSE){FastBeliefP[count+17]<-mydata$GuessFast.18.[i]
  jump<-18}
  if(is.na(mydata$GuessFast.19.[i])==FALSE){FastBeliefP[count+18]<-mydata$GuessFast.19.[i]
  jump<-19}
  if(is.na(mydata$GuessFast.20.[i])==FALSE){FastBeliefP[count+19]<-mydata$GuessFast.20.[i]
  jump<-20}
  if(is.na(mydata$GuessFast.21.[i])==FALSE){FastBeliefP[count+20]<-mydata$GuessFast.21.[i]
  jump<-21}
  if(is.na(mydata$GuessFast.22.[i])==FALSE){FastBeliefP[count+21]<-mydata$GuessFast.22.[i]
  jump<-22}
  if(is.na(mydata$GuessFast.23.[i])==FALSE){FastBeliefP[count+22]<-mydata$GuessFast.23.[i]
  jump<-23}
  if(is.na(mydata$GuessFast.24.[i])==FALSE){FastBeliefP[count+23]<-mydata$GuessFast.24.[i]
  jump<-24}
  if(is.na(mydata$GuessFast.25.[i])==FALSE){FastBeliefP[count+24]<-mydata$GuessFast.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#FastBeliefP <- FastBeliefP[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
head(FastBeliefP, 46)
table(FastBeliefP)

#SlowBeliefP is a 1x1854 vector 
SlowBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  SlowBeliefP[count]<-mydata$GuessSlow.1.[i]
  SlowBeliefP[count+1]<-mydata$GuessSlow.2.[i]
  SlowBeliefP[count+2]<-mydata$GuessSlow.3.[i]
  SlowBeliefP[count+3]<-mydata$GuessSlow.4.[i]
  SlowBeliefP[count+4]<-mydata$GuessSlow.5.[i]
  SlowBeliefP[count+5]<-mydata$GuessSlow.6.[i]
  SlowBeliefP[count+6]<-mydata$GuessSlow.7.[i]
  SlowBeliefP[count+7]<-mydata$GuessSlow.8.[i]
  SlowBeliefP[count+8]<-mydata$GuessSlow.9.[i]
  SlowBeliefP[count+9]<-mydata$GuessSlow.10.[i]
  SlowBeliefP[count+10]<-mydata$GuessSlow.11.[i]
  SlowBeliefP[count+11]<-mydata$GuessSlow.12.[i]
  SlowBeliefP[count+12]<-mydata$GuessSlow.13.[i]
  SlowBeliefP[count+13]<-mydata$GuessSlow.14.[i]
  SlowBeliefP[count+14]<-mydata$GuessSlow.15.[i]
  SlowBeliefP[count+15]<-mydata$GuessSlow.16.[i]
  SlowBeliefP[count+16]<-mydata$GuessSlow.17.[i]
  jump<-17
  if(is.na(mydata$GuessSlow.18.[i])==FALSE){SlowBeliefP[count+17]<-mydata$GuessSlow.18.[i]
  jump<-18}
  if(is.na(mydata$GuessSlow.19.[i])==FALSE){SlowBeliefP[count+18]<-mydata$GuessSlow.19.[i]
  jump<-19}
  if(is.na(mydata$GuessSlow.20.[i])==FALSE){SlowBeliefP[count+19]<-mydata$GuessSlow.20.[i]
  jump<-20}
  if(is.na(mydata$GuessSlow.21.[i])==FALSE){SlowBeliefP[count+20]<-mydata$GuessSlow.21.[i]
  jump<-21}
  if(is.na(mydata$GuessSlow.22.[i])==FALSE){SlowBeliefP[count+21]<-mydata$GuessSlow.22.[i]
  jump<-22}
  if(is.na(mydata$GuessSlow.23.[i])==FALSE){SlowBeliefP[count+22]<-mydata$GuessSlow.23.[i]
  jump<-23}
  if(is.na(mydata$GuessSlow.24.[i])==FALSE){SlowBeliefP[count+23]<-mydata$GuessSlow.24.[i]
  jump<-24}
  if(is.na(mydata$GuessSlow.25.[i])==FALSE){SlowBeliefP[count+24]<-mydata$GuessSlow.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#SlowBeliefP <- SlowBeliefP[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
tail(SlowBeliefP, 46)
table(SlowBeliefP)

#AutoBeliefP is a 1x1854 vector 
AutoBeliefP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  AutoBeliefP[count]<-mydata$GuessAuto.1.[i]
  AutoBeliefP[count+1]<-mydata$GuessAuto.2.[i]
  AutoBeliefP[count+2]<-mydata$GuessAuto.3.[i]
  AutoBeliefP[count+3]<-mydata$GuessAuto.4.[i]
  AutoBeliefP[count+4]<-mydata$GuessAuto.5.[i]
  AutoBeliefP[count+5]<-mydata$GuessAuto.6.[i]
  AutoBeliefP[count+6]<-mydata$GuessAuto.7.[i]
  AutoBeliefP[count+7]<-mydata$GuessAuto.8.[i]
  AutoBeliefP[count+8]<-mydata$GuessAuto.9.[i]
  AutoBeliefP[count+9]<-mydata$GuessAuto.10.[i]
  AutoBeliefP[count+10]<-mydata$GuessAuto.11.[i]
  AutoBeliefP[count+11]<-mydata$GuessAuto.12.[i]
  AutoBeliefP[count+12]<-mydata$GuessAuto.13.[i]
  AutoBeliefP[count+13]<-mydata$GuessAuto.14.[i]
  AutoBeliefP[count+14]<-mydata$GuessAuto.15.[i]
  AutoBeliefP[count+15]<-mydata$GuessAuto.16.[i]
  AutoBeliefP[count+16]<-mydata$GuessAuto.17.[i]
  jump<-17
  if(is.na(mydata$GuessAuto.18.[i])==FALSE){AutoBeliefP[count+17]<-mydata$GuessAuto.18.[i]
  jump<-18}
  if(is.na(mydata$GuessAuto.19.[i])==FALSE){AutoBeliefP[count+18]<-mydata$GuessAuto.19.[i]
  jump<-19}
  if(is.na(mydata$GuessAuto.20.[i])==FALSE){AutoBeliefP[count+19]<-mydata$GuessAuto.20.[i]
  jump<-20}
  if(is.na(mydata$GuessAuto.21.[i])==FALSE){AutoBeliefP[count+20]<-mydata$GuessAuto.21.[i]
  jump<-21}
  if(is.na(mydata$GuessAuto.22.[i])==FALSE){AutoBeliefP[count+21]<-mydata$GuessAuto.22.[i]
  jump<-22}
  if(is.na(mydata$GuessAuto.23.[i])==FALSE){AutoBeliefP[count+22]<-mydata$GuessAuto.23.[i]
  jump<-23}
  if(is.na(mydata$GuessAuto.24.[i])==FALSE){AutoBeliefP[count+23]<-mydata$GuessAuto.24.[i]
  jump<-24}
  if(is.na(mydata$GuessAuto.25.[i])==FALSE){AutoBeliefP[count+24]<-mydata$GuessAuto.25.[i]
  jump<-25}
  count<-count+jump
}
}
#This piece cuts out the 50 0 entries for Session 3 that pop up
#AutoBeliefP <- AutoBeliefP[c(1:405,411:427,433:449,455:471,477:493,499:515,521:537,543:559,565:581,587:603,609:6799)]
#2 NA entries for the last two players... fixes it
head(AutoBeliefP, 46)
table(AutoBeliefP)

#AutoFastSlowP is a 1x1854 vector where 0=Auto, 1=Fast, 2=Slow
AutoFastSlowP<-numeric(NumObsPun)
count<-1
jump<-0
for(i in 1:obs){if(mydata$ExpType[i]==4){
  AutoFastSlowP[count]<-ifelse(mydata$DrivingChoice.1.[i]==1, 0, ifelse(mydata$DrivingChoice.1.[i]==2, 2, 1))
  AutoFastSlowP[count+1]<-ifelse(mydata$DrivingChoice.2.[i]==1, 0, ifelse(mydata$DrivingChoice.2.[i]==2, 2, 1))
  AutoFastSlowP[count+2]<-ifelse(mydata$DrivingChoice.3.[i]==1, 0, ifelse(mydata$DrivingChoice.3.[i]==2, 2, 1))
  AutoFastSlowP[count+3]<-ifelse(mydata$DrivingChoice.4.[i]==1, 0, ifelse(mydata$DrivingChoice.4.[i]==2, 2, 1))
  AutoFastSlowP[count+4]<-ifelse(mydata$DrivingChoice.5.[i]==1, 0, ifelse(mydata$DrivingChoice.5.[i]==2, 2, 1))
  AutoFastSlowP[count+5]<-ifelse(mydata$DrivingChoice.6.[i]==1, 0, ifelse(mydata$DrivingChoice.6.[i]==2, 2, 1))
  AutoFastSlowP[count+6]<-ifelse(mydata$DrivingChoice.7.[i]==1, 0, ifelse(mydata$DrivingChoice.7.[i]==2, 2, 1))
  AutoFastSlowP[count+7]<-ifelse(mydata$DrivingChoice.8.[i]==1, 0, ifelse(mydata$DrivingChoice.8.[i]==2, 2, 1))
  AutoFastSlowP[count+8]<-ifelse(mydata$DrivingChoice.9.[i]==1, 0, ifelse(mydata$DrivingChoice.9.[i]==2, 2, 1))
  AutoFastSlowP[count+9]<-ifelse(mydata$DrivingChoice.10.[i]==1, 0, ifelse(mydata$DrivingChoice.10.[i]==2, 2, 1))
  AutoFastSlowP[count+10]<-ifelse(mydata$DrivingChoice.11.[i]==1, 0, ifelse(mydata$DrivingChoice.11.[i]==2, 2, 1))
  AutoFastSlowP[count+11]<-ifelse(mydata$DrivingChoice.12.[i]==1, 0, ifelse(mydata$DrivingChoice.12.[i]==2, 2, 1))
  AutoFastSlowP[count+12]<-ifelse(mydata$DrivingChoice.13.[i]==1, 0, ifelse(mydata$DrivingChoice.13.[i]==2, 2, 1))
  AutoFastSlowP[count+13]<-ifelse(mydata$DrivingChoice.14.[i]==1, 0, ifelse(mydata$DrivingChoice.14.[i]==2, 2, 1))
  AutoFastSlowP[count+14]<-ifelse(mydata$DrivingChoice.15.[i]==1, 0, ifelse(mydata$DrivingChoice.15.[i]==2, 2, 1))
  AutoFastSlowP[count+15]<-ifelse(mydata$DrivingChoice.16.[i]==1, 0, ifelse(mydata$DrivingChoice.16.[i]==2, 2, 1))
  AutoFastSlowP[count+16]<-ifelse(mydata$DrivingChoice.17.[i]==1, 0, ifelse(mydata$DrivingChoice.17.[i]==2, 2, 1))
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){AutoFastSlowP[count+17]<-ifelse(mydata$DrivingChoice.18.[i]==1, 0, ifelse(mydata$DrivingChoice.18.[i]==2, 2, 1))
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){AutoFastSlowP[count+18]<-ifelse(mydata$DrivingChoice.19.[i]==1, 0, ifelse(mydata$DrivingChoice.19.[i]==2, 2, 1)) 
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){AutoFastSlowP[count+19]<-ifelse(mydata$DrivingChoice.20.[i]==1, 0, ifelse(mydata$DrivingChoice.20.[i]==2, 2, 1))
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){AutoFastSlowP[count+20]<-ifelse(mydata$DrivingChoice.21.[i]==1, 0, ifelse(mydata$DrivingChoice.21.[i]==2, 2, 1))
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){AutoFastSlowP[count+21]<-ifelse(mydata$DrivingChoice.22.[i]==1, 0, ifelse(mydata$DrivingChoice.22.[i]==2, 2, 1))
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){AutoFastSlowP[count+22]<-ifelse(mydata$DrivingChoice.23.[i]==1, 0, ifelse(mydata$DrivingChoice.23.[i]==2, 2, 1))
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){AutoFastSlowP[count+23]<-ifelse(mydata$DrivingChoice.24.[i]==1, 0, ifelse(mydata$DrivingChoice.24.[i]==2, 2, 1))
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){AutoFastSlowP[count+24]<-ifelse(mydata$DrivingChoice.25.[i]==1, 0, ifelse(mydata$DrivingChoice.25.[i]==2, 2, 1))
  jump<-25}
  count<-count+jump
}
}
tail(AutoFastSlowP, 46)
table(AutoFastSlowP)
#Change numbers to names (optional)
for(i in 1:NumObsPun){ifelse(AutoFastSlowP[i]==1, AutoFastSlowP[i]<-"Fast", ifelse(AutoFastSlowP[i]==2, AutoFastSlowP[i]<-'Slow', AutoFastSlowP[i]<-'Auto'))}

#Triangle with 3 choices and 3 beliefs
Auto <- AutoBeliefP
Slow <- SlowBeliefP
Fast <- FastBeliefP
#Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
Choice <- AutoFastSlowP
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Choice)
BeliefTriP <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Punishment') +
  labs(fill = 'Choice') +
  theme_rgbw()#+
#scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
#scale_size_continuous(range = c(2.5, 7.5)) +
#theme(legend.position = c(0.82,.8),
#    legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
# theme(plot.title = element_text(hjust = 0.5))

#Subset with just the Fast choices
ChoiceFast <- subset(df, Choice == "Fast")
BeliefTriAFast <- ggtern(data = ChoiceFast, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Punishment') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Slow choices
ChoiceSlow <- subset(df, Choice == "Slow")
BeliefTriASlow <- ggtern(data = ChoiceSlow, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Punishment') +
  labs(fill = 'Choice') +
  theme_rgbw()#+

#Subset with just the Auto choices
ChoiceAuto <- subset(df, Choice == "Auto")
BeliefTriAAuto <- ggtern(data = ChoiceAuto, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Choice), size = 3, shape = 21, color = 'black') +
  labs(title='Choice by belief - Punishment') +
  labs(fill = 'Choice') +
  theme_rgbw()#+


### using multinom
dataP<-data.frame(AutoFastSlowP, FastBeliefP, SlowBeliefP, AutoBeliefP)
mlogitfitP<- multinom(AutoFastSlowP~FastBeliefP+SlowBeliefP+ AutoBeliefP, data=dataP)

summary(mlogitfitP)
z <- summary(mlogitfitP)$coefficients/summary(mlogitfitP)$standard.errors
z
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p




# Average payoff by round and driving choice

#RoundNum is a 1x6749 vector
RoundNum<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  RoundNum[count]<-1
  RoundNum[count+1]<-2
  RoundNum[count+2]<-3
  RoundNum[count+3]<-4
  RoundNum[count+4]<-5
  RoundNum[count+5]<-6
  RoundNum[count+6]<-7
  RoundNum[count+7]<-8
  RoundNum[count+8]<-9
  RoundNum[count+9]<-10
  RoundNum[count+10]<-11
  RoundNum[count+11]<-12
  RoundNum[count+12]<-13
  RoundNum[count+13]<-14
  RoundNum[count+14]<-15
  RoundNum[count+15]<-16
  RoundNum[count+16]<-17
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){RoundNum[count+17]<-18 
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){RoundNum[count+18]<-19
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){RoundNum[count+19]<-20
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){RoundNum[count+20]<-21
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){RoundNum[count+21]<-22
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){RoundNum[count+22]<-23
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){RoundNum[count+23]<-24
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){RoundNum[count+24]<-25
  jump<-25}
  count<-count+jump
}
tail(RoundNum, 50)
table(RoundNum)

#RoundNum5 is a 1x6749 vector
RoundNum5<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  RoundNum5[count]<-1
  RoundNum5[count+1]<-1
  RoundNum5[count+2]<-1
  RoundNum5[count+3]<-1
  RoundNum5[count+4]<-1
  RoundNum5[count+5]<-2
  RoundNum5[count+6]<-2
  RoundNum5[count+7]<-2
  RoundNum5[count+8]<-2
  RoundNum5[count+9]<-2
  RoundNum5[count+10]<-3
  RoundNum5[count+11]<-3
  RoundNum5[count+12]<-3
  RoundNum5[count+13]<-3
  RoundNum5[count+14]<-3
  RoundNum5[count+15]<-4
  RoundNum5[count+16]<-4
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){RoundNum5[count+17]<-4
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){RoundNum5[count+18]<-4
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){RoundNum5[count+19]<-4
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){RoundNum5[count+20]<-5
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){RoundNum5[count+21]<-5
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){RoundNum5[count+22]<-5
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){RoundNum5[count+23]<-5
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){RoundNum5[count+24]<-5
  jump<-25}
  count<-count+jump
}
tail(RoundNum5, 50)
table(RoundNum5)


#RoundNumLate is a 1x6749 vector
RoundNumLate<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  RoundNumLate[count]<-0
  RoundNumLate[count+1]<-0
  RoundNumLate[count+2]<-0
  RoundNumLate[count+3]<-0
  RoundNumLate[count+4]<-0
  RoundNumLate[count+5]<-0
  RoundNumLate[count+6]<-0
  RoundNumLate[count+7]<-0
  RoundNumLate[count+8]<-0
  RoundNumLate[count+9]<-0
  RoundNumLate[count+10]<-1
  RoundNumLate[count+11]<-1
  RoundNumLate[count+12]<-1
  RoundNumLate[count+13]<-1
  RoundNumLate[count+14]<-1
  RoundNumLate[count+15]<-1
  RoundNumLate[count+16]<-1
  jump<-17
  if(is.na(mydata$DrivingChoice.18.[i])==FALSE){RoundNumLate[count+17]<-1
  jump<-18}
  if(is.na(mydata$DrivingChoice.19.[i])==FALSE){RoundNumLate[count+18]<-1
  jump<-19}
  if(is.na(mydata$DrivingChoice.20.[i])==FALSE){RoundNumLate[count+19]<-1
  jump<-20}
  if(is.na(mydata$DrivingChoice.21.[i])==FALSE){RoundNumLate[count+20]<-1
  jump<-21}
  if(is.na(mydata$DrivingChoice.22.[i])==FALSE){RoundNumLate[count+21]<-1
  jump<-22}
  if(is.na(mydata$DrivingChoice.23.[i])==FALSE){RoundNumLate[count+22]<-1
  jump<-23}
  if(is.na(mydata$DrivingChoice.24.[i])==FALSE){RoundNumLate[count+23]<-1
  jump<-24}
  if(is.na(mydata$DrivingChoice.25.[i])==FALSE){RoundNumLate[count+24]<-1
  jump<-25}
  count<-count+jump
}
tail(RoundNumLate, 50)
table(RoundNumLate)



#ExpType is a 1x6749 vector 
ExpType<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  ExpType[count]<-mydata$ExpType[i]
  ExpType[count+1]<-mydata$ExpType[i]
  ExpType[count+2]<-mydata$ExpType[i]
  ExpType[count+3]<-mydata$ExpType[i]
  ExpType[count+4]<-mydata$ExpType[i]
  ExpType[count+5]<-mydata$ExpType[i]
  ExpType[count+6]<-mydata$ExpType[i]
  ExpType[count+7]<-mydata$ExpType[i]
  ExpType[count+8]<-mydata$ExpType[i]
  ExpType[count+9]<-mydata$ExpType[i]
  ExpType[count+10]<-mydata$ExpTyp[i]
  ExpType[count+11]<-mydata$ExpType[i]
  ExpType[count+12]<-mydata$ExpType[i]
  ExpType[count+13]<-mydata$ExpType[i]
  ExpType[count+14]<-mydata$ExpType[i]
  ExpType[count+15]<-mydata$ExpType[i]
  ExpType[count+16]<-mydata$ExpType[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){ExpType[count+17]<-mydata$ExpType[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){ExpType[count+18]<-mydata$ExpType[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){ExpType[count+19]<-mydata$ExpType[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){ExpType[count+20]<-mydata$ExpType[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){ExpType[count+21]<-mydata$ExpType[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){ExpType[count+22]<-mydata$ExpType[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){ExpType[count+23]<-mydata$ExpType[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){ExpType[count+24]<-mydata$ExpType[i]
  jump<-25}
  count<-count+jump
}
head(ExpType, 46)
table(ExpType)



Payoff<-numeric(NumObsTotal)
count<-1
jump<-0
for(i in 1:obs){
  Payoff[count]<-mydata$ChoicePayoff.1.[i]
  Payoff[count+1]<-mydata$ChoicePayoff.2.[i]
  Payoff[count+2]<-mydata$ChoicePayoff.3.[i]
  Payoff[count+3]<-mydata$ChoicePayoff.4.[i]
  Payoff[count+4]<-mydata$ChoicePayoff.5.[i]
  Payoff[count+5]<-mydata$ChoicePayoff.6.[i]
  Payoff[count+6]<-mydata$ChoicePayoff.7.[i]
  Payoff[count+7]<-mydata$ChoicePayoff.8.[i]
  Payoff[count+8]<-mydata$ChoicePayoff.9.[i]
  Payoff[count+9]<-mydata$ChoicePayoff.10.[i]
  Payoff[count+10]<-mydata$ChoicePayoff.11.[i]
  Payoff[count+11]<-mydata$ChoicePayoff.12.[i]
  Payoff[count+12]<-mydata$ChoicePayoff.13.[i]
  Payoff[count+13]<-mydata$ChoicePayoff.14.[i]
  Payoff[count+14]<-mydata$ChoicePayoff.15.[i]
  Payoff[count+15]<-mydata$ChoicePayoff.16.[i]
  Payoff[count+16]<-mydata$ChoicePayoff.17.[i]
  jump<-17
  if(is.na(mydata$ChoicePayoff.18.[i])==FALSE){Payoff[count+17]<-mydata$ChoicePayoff.18.[i]
  jump<-18}
  if(is.na(mydata$ChoicePayoff.19.[i])==FALSE){Payoff[count+18]<-mydata$ChoicePayoff.19.[i]
  jump<-19}
  if(is.na(mydata$ChoicePayoff.20.[i])==FALSE){Payoff[count+19]<-mydata$ChoicePayoff.20.[i]
  jump<-20}
  if(is.na(mydata$ChoicePayoff.21.[i])==FALSE){Payoff[count+20]<-mydata$ChoicePayoff.21.[i]
  jump<-21}
  if(is.na(mydata$ChoicePayoff.22.[i])==FALSE){Payoff[count+21]<-mydata$ChoicePayoff.22.[i]
  jump<-22}
  if(is.na(mydata$ChoicePayoff.23.[i])==FALSE){Payoff[count+22]<-mydata$ChoicePayoff.23.[i]
  jump<-23}
  if(is.na(mydata$ChoicePayoff.24.[i])==FALSE){Payoff[count+23]<-mydata$ChoicePayoff.24.[i]
  jump<-24}
  if(is.na(mydata$ChoicePayoff.25.[i])==FALSE){Payoff[count+24]<-mydata$ChoicePayoff.25.[i]
  jump<-25}
  count<-count+jump
}

df <- data.frame(RoundNum,RoundNum5,ExpType,Payoff,AutoFastSlow)
df$RoundNum <- as.factor(df$RoundNum)


#+++++++++++++++++++++++++
# Function to calculate the mean and the standard deviation
# for each group
#+++++++++++++++++++++++++
# data : a data frame
# varname : the name of a column containing the variable
#to be summariezed
# groupnames : vector of column names to be used as
# grouping variables
data_summary <- function(data, varname, groupnames){
  require(plyr)
  summary_func <- function(x, col){
    c(mean = mean(x[[col]], na.rm=TRUE),
      sd = sd(x[[col]], na.rm=TRUE))
  }
  data_sum<-ddply(data, groupnames, .fun=summary_func,
                  varname)
  data_sum <- rename(data_sum, c("mean" = varname))
  return(data_sum)
}

df2 <- data_summary(df, varname="Payoff", 
                    groupnames=c("ExpType", "RoundNum","AutoFastSlow"))
# Convert dose to a factor variable
df2$RoundNum=as.factor(df2$RoundNum)
head(df2)

ggplot(df2, aes(x=RoundNum, y=Payoff, group=ExpType, color=ExpType, shape=AutoFastSlow)) + 
  geom_pointrange(aes(ymin=Payoff-sd, ymax=Payoff+sd))


df2 <- data_summary(df, varname="Payoff", 
                    groupnames=c("ExpType", "RoundNum5","AutoFastSlow"))
# Convert dose to a factor variable
df2$RoundNum=as.factor(df2$RoundNum)
head(df2)

ggplot(df2, aes(x=RoundNum5, y=Payoff, group=ExpType, color=ExpType, shape=AutoFastSlow)) + 
  geom_pointrange(aes(ymin=Payoff-sd, ymax=Payoff+sd))


df2 <- data_summary(df, varname="Payoff", 
                    groupnames=c("RoundNum5","AutoFastSlow"))
# Convert dose to a factor variable
df2$RoundNum=as.factor(df2$RoundNum)
head(df2)

ggplot(df2, aes(x=RoundNum5, y=Payoff, group=AutoFastSlow, color=AutoFastSlow)) + 
  geom_pointrange(aes(ymin=Payoff-sd, ymax=Payoff+sd))




JitPercFast<-jitter(PercFast,factor=75)
JitPercSlow<-jitter(PercSlow,factor=75)
df <- data.frame(mydata$ExpType,JitPercFast,JitPercSlow)

ggplot(df, aes(x=JitPercFast, y=JitPercSlow, group=mydata$ExpType, color=mydata$ExpType)) + 
  geom_point() +scale_color_gradient(low="blue", high="red")



dfCF<-subset(df, mydata$ExpType==1 | mydata$ExpType==2)

ggplot(dfCF, aes(x=dfCF$JitPercFast, y=dfCF$JitPercSlow, group=dfCF$mydata.ExpType, color=dfCF$mydata.ExpType)) + 
  geom_point() +scale_color_gradient(low="blue", high="red")+xlim(-.1,1.1)+ylim(-.1,1.1)

dfCA<-subset(df, mydata$ExpType==1 | mydata$ExpType==3)

ggplot(dfCA, aes(x=dfCA$JitPercFast, y=dfCA$JitPercSlow, group=dfCA$mydata.ExpType, color=dfCA$mydata.ExpType)) + 
  geom_point() +scale_color_gradient(low="blue", high="red")+xlim(-.1,1.1)+ylim(-.1,1.1)


dfCP<-subset(df, mydata$ExpType==1 | mydata$ExpType==4)

ggplot(dfCP, aes(x=dfCP$JitPercFast, y=dfCP$JitPercSlow, group=dfCP$mydata.ExpType, color=dfCP$mydata.ExpType)) + 
  geom_point() +scale_color_gradient(low="blue", high="red")+xlim(-.1,1.1)+ylim(-.1,1.1)





PercFastC<-numeric()
PercSlowC<-numeric()
PercAutoC<-numeric()
j<-1
for(i in 1:obs){if(mydata$ExpType[i]==1){
  PercFastC[j]<-mydata$PercFast[i]
  PercSlowC[j]<-mydata$PercSlow[i]
  PercAutoC[j]<-mydata$PercAuto[i]
  j<-j+1
  }
}

PercFastP<-numeric()
PercSlowP<-numeric()
PercAutoP<-numeric()
j<-1
for(i in 1:obs){if(mydata$ExpType[i]==4){
  PercFastP[j]<-mydata$PercFast[i]
  PercSlowP[j]<-mydata$PercSlow[i]
  PercAutoP[j]<-mydata$PercAuto[i]
  j<-j+1
}
}

JitPercFastC<-jitter(PercFastC)
JitPercSlowC<-jitter(PercSlowC)

JitPercFastP<-jitter(PercFastP)
JitPercSlowP<-jitter(PercSlowP)

df <- data.frame(JitPercFastC,JitPercSlowC)
ggplot(df, aes(x=JitPercFastC, y=JitPercSlowC)) + 
  geom_point() +xlim(-0.1,1.1)+ylim(-0.1,1.1)

df <- data.frame(JitPercFastP,JitPercSlowP)
ggplot(df, aes(x=JitPercFastP, y=JitPercSlowP)) + 
  geom_point() +xlim(-0.1,1.1)+ylim(-0.1,1.1)



#AvgFastControl is the average guess for Fast in all control sessions by round matrix (session #, round #)
AvgFastControl<- numeric(25)
for(i in 1:18){AvgFastControl[i]<-(AvgActualFastSess1[i]+AvgActualFastSess6[i]+AvgActualFastSess7[i]+AvgActualFastSess10[i]+AvgActualFastSess14[i]+AvgActualFastSess15[i]+AvgActualFastSess20[i]+AvgActualFastSess26[i])/8}
AvgFastControl[19]<-(AvgActualFastSess1[19]+AvgActualFastSess7[19]+AvgActualFastSess10[19]+AvgActualFastSess14[19]+AvgActualFastSess15[19]+AvgActualFastSess20[19]+AvgActualFastSess26[19])/7
AvgFastControl[20]<-(AvgActualFastSess1[20]+AvgActualFastSess7[20]+AvgActualFastSess10[20]+AvgActualFastSess14[20]+AvgActualFastSess15[20]+AvgActualFastSess20[20])/6
AvgFastControl[21]<-(AvgActualFastSess1[21]+AvgActualFastSess7[21]+AvgActualFastSess10[21]+AvgActualFastSess15[21]+AvgActualFastSess20[21])/5
AvgFastControl[22]<-(AvgActualFastSess7[22]+AvgActualFastSess10[22]+AvgActualFastSess15[22]+AvgActualFastSess20[22])/4
AvgFastControl[23]<-(AvgActualFastSess7[23]+AvgActualFastSess10[23]+AvgActualFastSess15[23])/3
AvgFastControl[24]<-(AvgActualFastSess7[24]+AvgActualFastSess10[24])/2
AvgFastControl[25]<-(AvgActualFastSess7[25]+AvgActualFastSess10[25])/2

AvgFastFine<- numeric(25)
for(i in 1:18){AvgFastFine[i]<-(AvgActualFastSess2[i]+AvgActualFastSess5[i]+AvgActualFastSess8[i]+AvgActualFastSess12[i]+AvgActualFastSess16[i]+AvgActualFastSess18[i]+AvgActualFastSess22[i]+AvgActualFastSess24[i])/8}
AvgFastFine[19]<-(AvgActualFastSess2[19]+AvgActualFastSess5[19]+AvgActualFastSess8[19]+AvgActualFastSess12[19]+AvgActualFastSess16[19]+AvgActualFastSess22[19]+AvgActualFastSess24[19])/7
AvgFastFine[20]<-(AvgActualFastSess2[20]+AvgActualFastSess5[20]+AvgActualFastSess16[20]+AvgActualFastSess22[20]+AvgActualFastSess24[20])/5
AvgFastFine[21]<-(AvgActualFastSess2[21]+AvgActualFastSess16[21]+AvgActualFastSess22[21])/3
AvgFastFine[22]<-(AvgActualFastSess2[22]+AvgActualFastSess16[22]+AvgActualFastSess22[22])/3
AvgFastFine[23]<-NA
AvgFastFine[24]<-NA
AvgFastFine[25]<-NA

AvgFastAssoc<- numeric(25)
for(i in 1:17){AvgFastAssoc[i]<-(AvgActualFastSess3[i]+AvgActualFastSess4[i]+AvgActualFastSess9[i]+AvgActualFastSess11[i]+AvgActualFastSess13[i]+AvgActualFastSess17[i]+AvgActualFastSess19[i]+AvgActualFastSess21[i])/8}
AvgFastAssoc[18]<-(AvgActualFastSess4[18]+AvgActualFastSess9[18]+AvgActualFastSess11[18]+AvgActualFastSess13[18]+AvgActualFastSess17[18]+AvgActualFastSess19[18]+AvgActualFastSess21[18])/7
AvgFastAssoc[19]<-(AvgActualFastSess4[19]+AvgActualFastSess9[19]+AvgActualFastSess11[19]+AvgActualFastSess19[19]+AvgActualFastSess21[19])/5
AvgFastAssoc[20]<-(AvgActualFastSess19[20]+AvgActualFastSess21[20])/2
AvgFastAssoc[21]<-(AvgActualFastSess21[20])
AvgFastAssoc[22]<-NA
AvgFastAssoc[23]<-NA
AvgFastAssoc[24]<-NA
AvgFastAssoc[25]<-NA

AvgFastPun<- numeric(25)
for(i in 1:18){AvgFastPun[i]<-(AvgActualFastSess23[i]+AvgActualFastSess25[i]+AvgActualFastSess27[i]+AvgActualFastSess28[i]+AvgActualFastSess29[i]+AvgActualFastSess30[i]+AvgActualFastSess31[i]+AvgActualFastSess32[i])/8}
AvgFastPun[19]<-(AvgActualFastSess23[19]+AvgActualFastSess25[19]+AvgActualFastSess27[19]+AvgActualFastSess28[19]+AvgActualFastSess29[19]+AvgActualFastSess31[19]+AvgActualFastSess32[19])/7
AvgFastPun[20]<-(AvgActualFastSess23[20]+AvgActualFastSess25[20]+AvgActualFastSess27[20]+AvgActualFastSess28[20]+AvgActualFastSess29[20]+AvgActualFastSess31[20]+AvgActualFastSess32[20])/7
AvgFastPun[21]<-(AvgActualFastSess23[21]+AvgActualFastSess25[21]+AvgActualFastSess27[21]+AvgActualFastSess28[21]+AvgActualFastSess29[21]+AvgActualFastSess32[21])/6
AvgFastPun[22]<-(AvgActualFastSess23[22]+AvgActualFastSess25[22]+AvgActualFastSess28[22]+AvgActualFastSess29[22]+AvgActualFastSess32[22])/5
AvgFastPun[23]<-(AvgActualFastSess23[23]+AvgActualFastSess25[23]+AvgActualFastSess28[23]+AvgActualFastSess32[23])/4
AvgFastPun[24]<-(AvgActualFastSess25[24])
AvgFastPun[25]<-NA

#AvgAutoControl is the average guess for Auto in all control sessions by round matrix (session #, round #)
AvgAutoControl<- numeric(25)
for(i in 1:18){AvgAutoControl[i]<-(AvgActualAutoSess1[i]+AvgActualAutoSess6[i]+AvgActualAutoSess7[i]+AvgActualAutoSess10[i]+AvgActualAutoSess14[i]+AvgActualAutoSess15[i]+AvgActualAutoSess20[i]+AvgActualAutoSess26[i])/8}
AvgAutoControl[19]<-(AvgActualAutoSess1[19]+AvgActualAutoSess7[19]+AvgActualAutoSess10[19]+AvgActualAutoSess14[19]+AvgActualAutoSess15[19]+AvgActualAutoSess20[19]+AvgActualAutoSess26[19])/7
AvgAutoControl[20]<-(AvgActualAutoSess1[20]+AvgActualAutoSess7[20]+AvgActualAutoSess10[20]+AvgActualAutoSess14[20]+AvgActualAutoSess15[20]+AvgActualAutoSess20[20])/6
AvgAutoControl[21]<-(AvgActualAutoSess1[21]+AvgActualAutoSess7[21]+AvgActualAutoSess10[21]+AvgActualAutoSess15[21]+AvgActualAutoSess20[21])/5
AvgAutoControl[22]<-(AvgActualAutoSess7[22]+AvgActualAutoSess10[22]+AvgActualAutoSess15[22]+AvgActualAutoSess20[22])/4
AvgAutoControl[23]<-(AvgActualAutoSess7[23]+AvgActualAutoSess10[23]+AvgActualAutoSess15[23])/3
AvgAutoControl[24]<-(AvgActualAutoSess7[24]+AvgActualAutoSess10[24])/2
AvgAutoControl[25]<-(AvgActualAutoSess7[25]+AvgActualAutoSess10[25])/2

AvgAutoFine<- numeric(25)
for(i in 1:18){AvgAutoFine[i]<-(AvgActualAutoSess2[i]+AvgActualAutoSess5[i]+AvgActualAutoSess8[i]+AvgActualAutoSess12[i]+AvgActualAutoSess16[i]+AvgActualAutoSess18[i]+AvgActualAutoSess22[i]+AvgActualAutoSess24[i])/8}
AvgAutoFine[19]<-(AvgActualAutoSess2[19]+AvgActualAutoSess5[19]+AvgActualAutoSess8[19]+AvgActualAutoSess12[19]+AvgActualAutoSess16[19]+AvgActualAutoSess22[19]+AvgActualAutoSess24[19])/7
AvgAutoFine[20]<-(AvgActualAutoSess2[20]+AvgActualAutoSess5[20]+AvgActualAutoSess16[20]+AvgActualAutoSess22[20]+AvgActualAutoSess24[20])/5
AvgAutoFine[21]<-(AvgActualAutoSess2[21]+AvgActualAutoSess16[21]+AvgActualAutoSess22[21])/3
AvgAutoFine[22]<-(AvgActualAutoSess2[22]+AvgActualAutoSess16[22]+AvgActualAutoSess22[22])/3
AvgAutoFine[23]<-NA
AvgAutoFine[24]<-NA
AvgAutoFine[25]<-NA

AvgAutoAssoc<- numeric(25)
for(i in 1:17){AvgAutoAssoc[i]<-(AvgActualAutoSess3[i]+AvgActualAutoSess4[i]+AvgActualAutoSess9[i]+AvgActualAutoSess11[i]+AvgActualAutoSess13[i]+AvgActualAutoSess17[i]+AvgActualAutoSess19[i]+AvgActualAutoSess21[i])/8}
AvgAutoAssoc[18]<-(AvgActualAutoSess4[18]+AvgActualAutoSess9[18]+AvgActualAutoSess11[18]+AvgActualAutoSess13[18]+AvgActualAutoSess17[18]+AvgActualAutoSess19[18]+AvgActualAutoSess21[18])/7
AvgAutoAssoc[19]<-(AvgActualAutoSess4[19]+AvgActualAutoSess9[19]+AvgActualAutoSess11[19]+AvgActualAutoSess19[19]+AvgActualAutoSess21[19])/5
AvgAutoAssoc[20]<-(AvgActualAutoSess19[20]+AvgActualAutoSess21[20])/2
AvgAutoAssoc[21]<-(AvgActualAutoSess21[20])
AvgAutoAssoc[22]<-NA
AvgAutoAssoc[23]<-NA
AvgAutoAssoc[24]<-NA
AvgAutoAssoc[25]<-NA

AvgAutoPun<- numeric(25)
for(i in 1:18){AvgAutoPun[i]<-(AvgActualAutoSess23[i]+AvgActualAutoSess25[i]+AvgActualAutoSess27[i]+AvgActualAutoSess28[i]+AvgActualAutoSess29[i]+AvgActualAutoSess30[i]+AvgActualAutoSess31[i]+AvgActualAutoSess32[i])/8}
AvgAutoPun[19]<-(AvgActualAutoSess23[19]+AvgActualAutoSess25[19]+AvgActualAutoSess27[19]+AvgActualAutoSess28[19]+AvgActualAutoSess29[19]+AvgActualAutoSess31[19]+AvgActualAutoSess32[19])/7
AvgAutoPun[20]<-(AvgActualAutoSess23[20]+AvgActualAutoSess25[20]+AvgActualAutoSess27[20]+AvgActualAutoSess28[20]+AvgActualAutoSess29[20]+AvgActualAutoSess31[20]+AvgActualAutoSess32[20])/7
AvgAutoPun[21]<-(AvgActualAutoSess23[21]+AvgActualAutoSess25[21]+AvgActualAutoSess27[21]+AvgActualAutoSess28[21]+AvgActualAutoSess29[21]+AvgActualAutoSess32[21])/6
AvgAutoPun[22]<-(AvgActualAutoSess23[22]+AvgActualAutoSess25[22]+AvgActualAutoSess28[22]+AvgActualAutoSess29[22]+AvgActualAutoSess32[22])/5
AvgAutoPun[23]<-(AvgActualAutoSess23[23]+AvgActualAutoSess25[23]+AvgActualAutoSess28[23]+AvgActualAutoSess32[23])/4
AvgAutoPun[24]<-(AvgActualAutoSess25[24])
AvgAutoPun[25]<-NA


#AvgSlowControl is the average guess for Slow in all control sessions by round matrix (session #, round #)
AvgSlowControl<- numeric(25)
for(i in 1:18){AvgSlowControl[i]<-(AvgActualSlowSess1[i]+AvgActualSlowSess6[i]+AvgActualSlowSess7[i]+AvgActualSlowSess10[i]+AvgActualSlowSess14[i]+AvgActualSlowSess15[i]+AvgActualSlowSess20[i]+AvgActualSlowSess26[i])/8}
AvgSlowControl[19]<-(AvgActualSlowSess1[19]+AvgActualSlowSess7[19]+AvgActualSlowSess10[19]+AvgActualSlowSess14[19]+AvgActualSlowSess15[19]+AvgActualSlowSess20[19]+AvgActualSlowSess26[19])/7
AvgSlowControl[20]<-(AvgActualSlowSess1[20]+AvgActualSlowSess7[20]+AvgActualSlowSess10[20]+AvgActualSlowSess14[20]+AvgActualSlowSess15[20]+AvgActualSlowSess20[20])/6
AvgSlowControl[21]<-(AvgActualSlowSess1[21]+AvgActualSlowSess7[21]+AvgActualSlowSess10[21]+AvgActualSlowSess15[21]+AvgActualSlowSess20[21])/5
AvgSlowControl[22]<-(AvgActualSlowSess7[22]+AvgActualSlowSess10[22]+AvgActualSlowSess15[22]+AvgActualSlowSess20[22])/4
AvgSlowControl[23]<-(AvgActualSlowSess7[23]+AvgActualSlowSess10[23]+AvgActualSlowSess15[23])/3
AvgSlowControl[24]<-(AvgActualSlowSess7[24]+AvgActualSlowSess10[24])/2
AvgSlowControl[25]<-(AvgActualSlowSess7[25]+AvgActualSlowSess10[25])/2

AvgSlowFine<- numeric(25)
for(i in 1:18){AvgSlowFine[i]<-(AvgActualSlowSess2[i]+AvgActualSlowSess5[i]+AvgActualSlowSess8[i]+AvgActualSlowSess12[i]+AvgActualSlowSess16[i]+AvgActualSlowSess18[i]+AvgActualSlowSess22[i]+AvgActualSlowSess24[i])/8}
AvgSlowFine[19]<-(AvgActualSlowSess2[19]+AvgActualSlowSess5[19]+AvgActualSlowSess8[19]+AvgActualSlowSess12[19]+AvgActualSlowSess16[19]+AvgActualSlowSess22[19]+AvgActualSlowSess24[19])/7
AvgSlowFine[20]<-(AvgActualSlowSess2[20]+AvgActualSlowSess5[20]+AvgActualSlowSess16[20]+AvgActualSlowSess22[20]+AvgActualSlowSess24[20])/5
AvgSlowFine[21]<-(AvgActualSlowSess2[21]+AvgActualSlowSess16[21]+AvgActualSlowSess22[21])/3
AvgSlowFine[22]<-(AvgActualSlowSess2[22]+AvgActualSlowSess16[22]+AvgActualSlowSess22[22])/3
AvgSlowFine[23]<-NA
AvgSlowFine[24]<-NA
AvgSlowFine[25]<-NA

AvgSlowAssoc<- numeric(25)
for(i in 1:17){AvgSlowAssoc[i]<-(AvgActualSlowSess3[i]+AvgActualSlowSess4[i]+AvgActualSlowSess9[i]+AvgActualSlowSess11[i]+AvgActualSlowSess13[i]+AvgActualSlowSess17[i]+AvgActualSlowSess19[i]+AvgActualSlowSess21[i])/8}
AvgSlowAssoc[18]<-(AvgActualSlowSess4[18]+AvgActualSlowSess9[18]+AvgActualSlowSess11[18]+AvgActualSlowSess13[18]+AvgActualSlowSess17[18]+AvgActualSlowSess19[18]+AvgActualSlowSess21[18])/7
AvgSlowAssoc[19]<-(AvgActualSlowSess4[19]+AvgActualSlowSess9[19]+AvgActualSlowSess11[19]+AvgActualSlowSess19[19]+AvgActualSlowSess21[19])/5
AvgSlowAssoc[20]<-(AvgActualSlowSess19[20]+AvgActualSlowSess21[20])/2
AvgSlowAssoc[21]<-(AvgActualSlowSess21[20])
AvgSlowAssoc[22]<-NA
AvgSlowAssoc[23]<-NA
AvgSlowAssoc[24]<-NA
AvgSlowAssoc[25]<-NA

AvgSlowPun<- numeric(25)
for(i in 1:18){AvgSlowPun[i]<-(AvgActualSlowSess23[i]+AvgActualSlowSess25[i]+AvgActualSlowSess27[i]+AvgActualSlowSess28[i]+AvgActualSlowSess29[i]+AvgActualSlowSess30[i]+AvgActualSlowSess31[i]+AvgActualSlowSess32[i])/8}
AvgSlowPun[19]<-(AvgActualSlowSess23[19]+AvgActualSlowSess25[19]+AvgActualSlowSess27[19]+AvgActualSlowSess28[19]+AvgActualSlowSess29[19]+AvgActualSlowSess31[19]+AvgActualSlowSess32[19])/7
AvgSlowPun[20]<-(AvgActualSlowSess23[20]+AvgActualSlowSess25[20]+AvgActualSlowSess27[20]+AvgActualSlowSess28[20]+AvgActualSlowSess29[20]+AvgActualSlowSess31[20]+AvgActualSlowSess32[20])/7
AvgSlowPun[21]<-(AvgActualSlowSess23[21]+AvgActualSlowSess25[21]+AvgActualSlowSess27[21]+AvgActualSlowSess28[21]+AvgActualSlowSess29[21]+AvgActualSlowSess32[21])/6
AvgSlowPun[22]<-(AvgActualSlowSess23[22]+AvgActualSlowSess25[22]+AvgActualSlowSess28[22]+AvgActualSlowSess29[22]+AvgActualSlowSess32[22])/5
AvgSlowPun[23]<-(AvgActualSlowSess23[23]+AvgActualSlowSess25[23]+AvgActualSlowSess28[23]+AvgActualSlowSess32[23])/4
AvgSlowPun[24]<-(AvgActualSlowSess25[24])
AvgSlowPun[25]<-NA

#Comparing averages across treatments by round

data <- data.frame(AvgFastControl,AvgFastFine,AvgFastAssoc,AvgFastPun)
FastPlotAvgs <- plot_ly(data, x = ~x, y = ~AvgFastControl, name = 'Control', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgFastFine, name = 'Fine', mode = 'lines+markers') %>%
  add_trace(y = ~AvgFastAssoc, name = 'Association', mode = 'lines+markers')%>%
  add_trace(y = ~AvgFastPun, name = 'Punishment', mode = 'lines+markers')%>%
  layout(title = "Fast Across treatments",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 60),title = "Proportion"))
FastPlotAvgs

data <- data.frame(AvgAutoControl,AvgAutoFine,AvgAutoAssoc,AvgAutoPun)
AutoPlotAvgs <- plot_ly(data, x = ~x, y = ~AvgAutoControl, name = 'Control', type = 'scatter', mode = 'lines+markers') %>%
      add_trace(y = ~AvgAutoFine, name = 'Fine', mode = 'lines+markers') %>%
  add_trace(y = ~AvgAutoAssoc, name = 'Association', mode = 'lines+markers')%>%
    add_trace(y = ~AvgAutoPun, name = 'Punishment', mode = 'lines+markers')%>%
  layout(title = "Auto Across treatments",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 60),title = "Proportion"))
AutoPlotAvgs

data <- data.frame(AvgSlowControl,AvgSlowFine,AvgSlowAssoc,AvgSlowPun)
SlowPlotAvgs <- plot_ly(data, x = ~x, y = ~AvgSlowControl, name = 'Control', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgSlowFine, name = 'Fine', mode = 'lines+markers') %>%
  add_trace(y = ~AvgSlowAssoc, name = 'Association', mode = 'lines+markers')%>%
  add_trace(y = ~AvgSlowPun, name = 'Punishment', mode = 'lines+markers')%>%
  layout(title = "Slow Across treatments",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 60),title = "Proportion"))
SlowPlotAvgs


Auto <- AvgAutoControl
Slow <- AvgSlowControl
Fast <- AvgFastControl
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
ControlTri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Avg of Control sessions') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))


Auto <- AvgAutoFine
Slow <- AvgSlowFine
Fast <- AvgFastFine
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
FineTri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Avg of Fine sessions') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))


Auto <- AvgAutoAssoc
Slow <- AvgSlowAssoc
Fast <- AvgFastAssoc
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
AssocTri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Avg of Association sessions') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))


Auto <- AvgAutoPun
Slow <- AvgSlowPun
Fast <- AvgFastPun
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
PunTri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Avg of Punishment sessions') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))


SpeedC<-numeric(173)
SpeedF<-numeric(163)
SpeedA<-numeric(151)
SpeedP<-numeric(174)

sum(mydata$ExpType==1 & mydata$ComputerStation==1)

j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==1 & mydata$ComputerStation[i]==1){
    SpeedC[j]<- mydata$AvgSpeed.1.[i]
    SpeedC[j+1]<- mydata$AvgSpeed.2.[i]
    SpeedC[j+2]<- mydata$AvgSpeed.3.[i]
    SpeedC[j+3]<- mydata$AvgSpeed.4.[i]
    SpeedC[j+4]<- mydata$AvgSpeed.5.[i]
    SpeedC[j+5]<- mydata$AvgSpeed.6.[i]
    SpeedC[j+6]<- mydata$AvgSpeed.7.[i]
    SpeedC[j+7]<- mydata$AvgSpeed.8.[i]
    SpeedC[j+8]<- mydata$AvgSpeed.9.[i]
    SpeedC[j+9]<- mydata$AvgSpeed.10.[i]
    SpeedC[j+10]<- mydata$AvgSpeed.11.[i]
    SpeedC[j+11]<- mydata$AvgSpeed.12.[i]
    SpeedC[j+12]<- mydata$AvgSpeed.13.[i]
    SpeedC[j+13]<- mydata$AvgSpeed.14.[i]
    SpeedC[j+14]<- mydata$AvgSpeed.15.[i]
    SpeedC[j+15]<- mydata$AvgSpeed.16.[i]
    SpeedC[j+16]<- mydata$AvgSpeed.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      SpeedC[j]<- mydata$AvgSpeed.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      SpeedC[j]<- mydata$AvgSpeed.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      SpeedC[j]<- mydata$AvgSpeed.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      SpeedC[j]<- mydata$AvgSpeed.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      SpeedC[j]<- mydata$AvgSpeed.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      SpeedC[j]<- mydata$AvgSpeed.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      SpeedC[j]<- mydata$AvgSpeed.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      SpeedC[j]<- mydata$AvgSpeed.25.[i]
      j<-j+1
    }
  }
}
SpeedC




j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==2& mydata$ComputerStation[i]==1){
    SpeedF[j]<- mydata$AvgSpeed.1.[i]
    SpeedF[j+1]<- mydata$AvgSpeed.2.[i]
    SpeedF[j+2]<- mydata$AvgSpeed.3.[i]
    SpeedF[j+3]<- mydata$AvgSpeed.4.[i]
    SpeedF[j+4]<- mydata$AvgSpeed.5.[i]
    SpeedF[j+5]<- mydata$AvgSpeed.6.[i]
    SpeedF[j+6]<- mydata$AvgSpeed.7.[i]
    SpeedF[j+7]<- mydata$AvgSpeed.8.[i]
    SpeedF[j+8]<- mydata$AvgSpeed.9.[i]
    SpeedF[j+9]<- mydata$AvgSpeed.10.[i]
    SpeedF[j+10]<- mydata$AvgSpeed.11.[i]
    SpeedF[j+11]<- mydata$AvgSpeed.12.[i]
    SpeedF[j+12]<- mydata$AvgSpeed.13.[i]
    SpeedF[j+13]<- mydata$AvgSpeed.14.[i]
    SpeedF[j+14]<- mydata$AvgSpeed.15.[i]
    SpeedF[j+15]<- mydata$AvgSpeed.16.[i]
    SpeedF[j+16]<- mydata$AvgSpeed.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      SpeedF[j]<- mydata$AvgSpeed.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      SpeedF[j]<- mydata$AvgSpeed.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      SpeedF[j]<- mydata$AvgSpeed.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      SpeedF[j]<- mydata$AvgSpeed.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      SpeedF[j]<- mydata$AvgSpeed.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      SpeedF[j]<- mydata$AvgSpeed.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      SpeedF[j]<- mydata$AvgSpeed.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      SpeedF[j]<- mydata$AvgSpeed.25.[i]
      j<-j+1
    }
  }
}


j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==3& mydata$ComputerStation[i]==1){
    SpeedA[j]<- mydata$AvgSpeed.1.[i]
    SpeedA[j+1]<- mydata$AvgSpeed.2.[i]
    SpeedA[j+2]<- mydata$AvgSpeed.3.[i]
    SpeedA[j+3]<- mydata$AvgSpeed.4.[i]
    SpeedA[j+4]<- mydata$AvgSpeed.5.[i]
    SpeedA[j+5]<- mydata$AvgSpeed.6.[i]
    SpeedA[j+6]<- mydata$AvgSpeed.7.[i]
    SpeedA[j+7]<- mydata$AvgSpeed.8.[i]
    SpeedA[j+8]<- mydata$AvgSpeed.9.[i]
    SpeedA[j+9]<- mydata$AvgSpeed.10.[i]
    SpeedA[j+10]<- mydata$AvgSpeed.11.[i]
    SpeedA[j+11]<- mydata$AvgSpeed.12.[i]
    SpeedA[j+12]<- mydata$AvgSpeed.13.[i]
    SpeedA[j+13]<- mydata$AvgSpeed.14.[i]
    SpeedA[j+14]<- mydata$AvgSpeed.15.[i]
    SpeedA[j+15]<- mydata$AvgSpeed.16.[i]
    SpeedA[j+16]<- mydata$AvgSpeed.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      SpeedA[j]<- mydata$AvgSpeed.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      SpeedA[j]<- mydata$AvgSpeed.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      SpeedA[j]<- mydata$AvgSpeed.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      SpeedA[j]<- mydata$AvgSpeed.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      SpeedA[j]<- mydata$AvgSpeed.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      SpeedA[j]<- mydata$AvgSpeed.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      SpeedA[j]<- mydata$AvgSpeed.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      SpeedA[j]<- mydata$AvgSpeed.25.[i]
      j<-j+1
    }
  }
}


j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==4& mydata$ComputerStation[i]==1){
    SpeedP[j]<- mydata$AvgSpeed.1.[i]
    SpeedP[j+1]<- mydata$AvgSpeed.2.[i]
    SpeedP[j+2]<- mydata$AvgSpeed.3.[i]
    SpeedP[j+3]<- mydata$AvgSpeed.4.[i]
    SpeedP[j+4]<- mydata$AvgSpeed.5.[i]
    SpeedP[j+5]<- mydata$AvgSpeed.6.[i]
    SpeedP[j+6]<- mydata$AvgSpeed.7.[i]
    SpeedP[j+7]<- mydata$AvgSpeed.8.[i]
    SpeedP[j+8]<- mydata$AvgSpeed.9.[i]
    SpeedP[j+9]<- mydata$AvgSpeed.10.[i]
    SpeedP[j+10]<- mydata$AvgSpeed.11.[i]
    SpeedP[j+11]<- mydata$AvgSpeed.12.[i]
    SpeedP[j+12]<- mydata$AvgSpeed.13.[i]
    SpeedP[j+13]<- mydata$AvgSpeed.14.[i]
    SpeedP[j+14]<- mydata$AvgSpeed.15.[i]
    SpeedP[j+15]<- mydata$AvgSpeed.16.[i]
    SpeedP[j+16]<- mydata$AvgSpeed.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      SpeedP[j]<- mydata$AvgSpeed.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      SpeedP[j]<- mydata$AvgSpeed.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      SpeedP[j]<- mydata$AvgSpeed.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      SpeedP[j]<- mydata$AvgSpeed.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      SpeedP[j]<- mydata$AvgSpeed.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      SpeedP[j]<- mydata$AvgSpeed.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      SpeedP[j]<- mydata$AvgSpeed.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      SpeedP[j]<- mydata$AvgSpeed.25.[i]
      j<-j+1
    }
  }
}

t.test(SpeedC,SpeedP)
ks.test(SpeedC,SpeedP)


#Many obs...
pop1<-SpeedC
pop2<-SpeedF
pop3<-SpeedA
pop4<-SpeedP

# You have to turn the variable into a data frame to use ggplot
pop1.data <- data.frame(pop1)
pop2.data <- data.frame(pop2)
pop3.data <- data.frame(pop3)
pop4.data <- data.frame(pop4)

pop1.data$type <- NA
pop2.data$type <- NA
pop3.data$type <- NA
pop4.data$type <- NA
pop1.data$type <- 'Control'
pop2.data$type <- 'Fine'
pop3.data$type <- 'Assoc'
pop4.data$type <- 'Pun'


colnames(pop1.data) <- c("Speed", "Condition")
colnames(pop2.data) <- c("Speed", "Condition")
colnames(pop3.data) <- c("Speed", "Condition")
colnames(pop4.data) <- c("Speed", "Condition")

p1vsp2vsp3vsp4<- rbind(pop1.data, pop2.data, pop3.data, pop4.data)


plot1 <- ggplot(p1vsp2vsp3vsp4, aes(Speed, fill=Condition,linetype=Condition)) + stat_ecdf(aes(colour=Condition)) + labs(x = "Population Speed", y = "Proportion")+ 
  theme_classic()+xlim(0.8,1.9)#+scale_color_manual(values=c('#000000','#E69F00'))+
#annotation_custom(my_grob1)+xlim(0,100)+ylim(0,1)


mean(SpeedC)
mean(SpeedF)
mean(SpeedA)
mean(SpeedP)
t.test(SpeedC,SpeedF)
ks.test(SpeedC,SpeedF)

t.test(SpeedC,SpeedA)
ks.test(SpeedC,SpeedA)

t.test(SpeedC,SpeedP)
ks.test(SpeedC,SpeedP)


#AvgSpeed is a matrix (session #, round #)
AvgSpeed<- matrix(nrow=max(mydata$Sess), ncol=25)
count<-1
for(j in 1:25){
  for(i in 1:obs){if(mydata$Sess[j]==j){
    AvgSpeed[count,1]<-mean(mydata[mydata$Sess==count,"AvgSpeed.1."])
    AvgSpeed[count,2]<-mean(mydata[mydata$Sess==count,"AvgSpeed.2."])
    AvgSpeed[count,3]<-mean(mydata[mydata$Sess==count,"AvgSpeed.3."])
    AvgSpeed[count,4]<-mean(mydata[mydata$Sess==count,"AvgSpeed.4."])
    AvgSpeed[count,5]<-mean(mydata[mydata$Sess==count,"AvgSpeed.5."])
    AvgSpeed[count,6]<-mean(mydata[mydata$Sess==count,"AvgSpeed.6."])
    AvgSpeed[count,7]<-mean(mydata[mydata$Sess==count,"AvgSpeed.7."])
    AvgSpeed[count,8]<-mean(mydata[mydata$Sess==count,"AvgSpeed.8."])
    AvgSpeed[count,9]<-mean(mydata[mydata$Sess==count,"AvgSpeed.9."])
    AvgSpeed[count,10]<-mean(mydata[mydata$Sess==count,"AvgSpeed.10."])
    AvgSpeed[count,11]<-mean(mydata[mydata$Sess==count,"AvgSpeed.11."])
    AvgSpeed[count,12]<-mean(mydata[mydata$Sess==count,"AvgSpeed.12."])
    AvgSpeed[count,13]<-mean(mydata[mydata$Sess==count,"AvgSpeed.13."])
    AvgSpeed[count,14]<-mean(mydata[mydata$Sess==count,"AvgSpeed.14."])
    AvgSpeed[count,15]<-mean(mydata[mydata$Sess==count,"AvgSpeed.15."])
    AvgSpeed[count,16]<-mean(mydata[mydata$Sess==count,"AvgSpeed.16."])
    AvgSpeed[count,17]<-mean(mydata[mydata$Sess==count,"AvgSpeed.17."])
    AvgSpeed[count,18]<-mean(mydata[mydata$Sess==count,"AvgSpeed.18."])
    AvgSpeed[count,19]<-mean(mydata[mydata$Sess==count,"AvgSpeed.19."])
    AvgSpeed[count,20]<-mean(mydata[mydata$Sess==count,"AvgSpeed.20."])
    AvgSpeed[count,21]<-mean(mydata[mydata$Sess==count,"AvgSpeed.21."])
    AvgSpeed[count,22]<-mean(mydata[mydata$Sess==count,"AvgSpeed.22."])
    AvgSpeed[count,23]<-mean(mydata[mydata$Sess==count,"AvgSpeed.23."])
    AvgSpeed[count,24]<-mean(mydata[mydata$Sess==count,"AvgSpeed.24."])
    AvgSpeed[count,25]<-mean(mydata[mydata$Sess==count,"AvgSpeed.25."])
    count<-count+1
  }}
  count<-1
}

#To see the average guess fast over all rounds in session 30
AvgSpeed[32,]

AvgSpeedReg<-numeric(661)
count<-1
countt<-1
for(x in 1:32){
  for(j in 1:25){
    AvgSpeedReg[countt]<-AvgSpeed[count,j]
    countt<-countt+1
    }
  count<-count+1
}

AvgSpeedReg<-na.omit(AvgSpeedReg)

#AvgSpeedControl is the average speed in all control sessions 
AvgSpeedControl<- numeric(25)
AvgSpeedFine<- numeric(25)
AvgSpeedAssoc<- numeric(25)
AvgSpeedPun<- numeric(25)
count<-1
for(j in 1:25){
  AvgSpeedControl[count]<-(AvgSpeed[1,count]+AvgSpeed[6,count]+AvgSpeed[7,count]+AvgSpeed[10,count]+AvgSpeed[14,count]+AvgSpeed[15,count]+AvgSpeed[20,count]+AvgSpeed[26,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgSpeedFine[count]<-(AvgSpeed[2,count]+AvgSpeed[5,count]+AvgSpeed[8,count]+AvgSpeed[12,count]+AvgSpeed[16,count]+AvgSpeed[18,count]+AvgSpeed[22,count]+AvgSpeed[24,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgSpeedAssoc[count]<-(AvgSpeed[3,count]+AvgSpeed[4,count]+AvgSpeed[9,count]+AvgSpeed[11,count]+AvgSpeed[13,count]+AvgSpeed[17,count]+AvgSpeed[19,count]+AvgSpeed[21,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgSpeedPun[count]<-(AvgSpeed[23,count]+AvgSpeed[25,count]+AvgSpeed[27,count]+AvgSpeed[28,count]+AvgSpeed[29,count]+AvgSpeed[30,count]+AvgSpeed[31,count]+AvgSpeed[32,count])/8
  count<-count+1
}



#COME BACK HERE


#AvgSpeedControl is the average speed in all control sessions 
AvgSpeedControlF<- numeric(25)
AvgSpeedFineF<- numeric(25)
AvgSpeedAssocF<- numeric(25)
AvgSpeedPunF<- numeric(25)
count<-1
for(j in 1:25){
  AvgSpeedControl[count]<-(AvgSpeed[1,count]+AvgSpeed[6,count]+AvgSpeed[7,count]+AvgSpeed[10,count]+AvgSpeed[14,count]+AvgSpeed[15,count]+AvgSpeed[20,count]+AvgSpeed[26,count])/8
  count<-count+1
}

SSSSSSS

#Graph of the average guess of fast in each Treatment
X<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)
data <- data.frame(X,AvgSpeedControl, AvgSpeedFine,AvgSpeedAssoc,AvgSpeedPun)
data
#AvgSpeedPlotTreat <- plot_ly(data, z = ~z, y = ~AvgSpeedControl, name = 'Control', type = 'scatter', mode = 'lines+markers') %>%
AvgSpeedPlotTreat <- ggplot(data, z = ~z, y = ~AvgSpeedControl, name = 'Control', type = 'scatter', mode = 'lines+markers') +
  add_trace(y = ~AvgSpeedFine, name = 'Fine', mode = 'lines+markers') +
  add_trace(y = ~AvgSpeedAssoc, name = 'Assoc', mode = 'lines+markers')+
  add_trace(y = ~AvgSpeedPun, name = 'Pun', mode = 'lines+markers')+
  layout(title = "AvgSpeed ",
         xaxis = list(range = c(0, 18),title = "Round"),
         yaxis = list(range = c(1.1, 1.5),title = "Speed"))

AvgSpeedPlotTreat

ggplot(data=data, aes(x=X,y=AvgSpeedControl, group=1)) + geom_line()+ geom_point()+
  geom_line(y = AvgSpeedFine, name = 'Fine', group=2,linetype="dashed", color="blue", size=1.2) + geom_line()+ geom_point()+
  geom_line(y = AvgSpeedAssoc, name = 'Assoc', group=2,linetype="dashed", color="red", size=1.2) + geom_line()+ geom_point()+
  geom_line(y = AvgSpeedPun, name = 'Pun', group=2,linetype="dashed", color="grey", size=1.2) + geom_line()+ geom_point()#+



ggplot(data, z = ~z, y = ~AvgSpeedControl, name = 'Control', type = 'scatter', mode = 'lines+markers')





##CDF of time by treatment
TimeC<-numeric(NumObsControl)
TimeF<-numeric(NumObsFine)
TimeA<-numeric(NumObsAssoc)
TimeP<-numeric(NumObsPun)



#Creating one vector with all the time observations by treatment
j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==1){
    TimeC[j]<- mydata$DecTime.1.[i]
    TimeC[j+1]<- mydata$DecTime.2.[i]
    TimeC[j+2]<- mydata$DecTime.3.[i]
    TimeC[j+3]<- mydata$DecTime.4.[i]
    TimeC[j+4]<- mydata$DecTime.5.[i]
    TimeC[j+5]<- mydata$DecTime.6.[i]
    TimeC[j+6]<- mydata$DecTime.7.[i]
    TimeC[j+7]<- mydata$DecTime.8.[i]
    TimeC[j+8]<- mydata$DecTime.9.[i]
    TimeC[j+9]<- mydata$DecTime.10.[i]
    TimeC[j+10]<- mydata$DecTime.11.[i]
    TimeC[j+11]<- mydata$DecTime.12.[i]
    TimeC[j+12]<- mydata$DecTime.13.[i]
    TimeC[j+13]<- mydata$DecTime.14.[i]
    TimeC[j+14]<- mydata$DecTime.15.[i]
    TimeC[j+15]<- mydata$DecTime.16.[i]
    TimeC[j+16]<- mydata$DecTime.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      TimeC[j]<- mydata$DecTime.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      TimeC[j]<- mydata$DecTime.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      TimeC[j]<- mydata$DecTime.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      TimeC[j]<- mydata$DecTime.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      TimeC[j]<- mydata$DecTime.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      TimeC[j]<- mydata$DecTime.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      TimeC[j]<- mydata$DecTime.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      TimeC[j]<- mydata$DecTime.25.[i]
      j<-j+1
    }
  }
}
j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==2){
    TimeF[j]<- mydata$DecTime.1.[i]
    TimeF[j+1]<- mydata$DecTime.2.[i]
    TimeF[j+2]<- mydata$DecTime.3.[i]
    TimeF[j+3]<- mydata$DecTime.4.[i]
    TimeF[j+4]<- mydata$DecTime.5.[i]
    TimeF[j+5]<- mydata$DecTime.6.[i]
    TimeF[j+6]<- mydata$DecTime.7.[i]
    TimeF[j+7]<- mydata$DecTime.8.[i]
    TimeF[j+8]<- mydata$DecTime.9.[i]
    TimeF[j+9]<- mydata$DecTime.10.[i]
    TimeF[j+10]<- mydata$DecTime.11.[i]
    TimeF[j+11]<- mydata$DecTime.12.[i]
    TimeF[j+12]<- mydata$DecTime.13.[i]
    TimeF[j+13]<- mydata$DecTime.14.[i]
    TimeF[j+14]<- mydata$DecTime.15.[i]
    TimeF[j+15]<- mydata$DecTime.16.[i]
    TimeF[j+16]<- mydata$DecTime.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      TimeF[j]<- mydata$DecTime.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      TimeF[j]<- mydata$DecTime.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      TimeF[j]<- mydata$DecTime.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      TimeF[j]<- mydata$DecTime.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      TimeF[j]<- mydata$DecTime.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      TimeF[j]<- mydata$DecTime.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      TimeF[j]<- mydata$DecTime.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      TimeF[j]<- mydata$DecTime.25.[i]
      j<-j+1
    }
  }
}

j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==3){
    TimeA[j]<- mydata$DecTime.1.[i]
    TimeA[j+1]<- mydata$DecTime.2.[i]
    TimeA[j+2]<- mydata$DecTime.3.[i]
    TimeA[j+3]<- mydata$DecTime.4.[i]
    TimeA[j+4]<- mydata$DecTime.5.[i]
    TimeA[j+5]<- mydata$DecTime.6.[i]
    TimeA[j+6]<- mydata$DecTime.7.[i]
    TimeA[j+7]<- mydata$DecTime.8.[i]
    TimeA[j+8]<- mydata$DecTime.9.[i]
    TimeA[j+9]<- mydata$DecTime.10.[i]
    TimeA[j+10]<- mydata$DecTime.11.[i]
    TimeA[j+11]<- mydata$DecTime.12.[i]
    TimeA[j+12]<- mydata$DecTime.13.[i]
    TimeA[j+13]<- mydata$DecTime.14.[i]
    TimeA[j+14]<- mydata$DecTime.15.[i]
    TimeA[j+15]<- mydata$DecTime.16.[i]
    TimeA[j+16]<- mydata$DecTime.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      TimeA[j]<- mydata$DecTime.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      TimeA[j]<- mydata$DecTime.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      TimeA[j]<- mydata$DecTime.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      TimeA[j]<- mydata$DecTime.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      TimeA[j]<- mydata$DecTime.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      TimeA[j]<- mydata$DecTime.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      TimeA[j]<- mydata$DecTime.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      TimeA[j]<- mydata$DecTime.25.[i]
      j<-j+1
    }
  }
}

j<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==4){
    TimeP[j]<- mydata$DecTime.1.[i]
    TimeP[j+1]<- mydata$DecTime.2.[i]
    TimeP[j+2]<- mydata$DecTime.3.[i]
    TimeP[j+3]<- mydata$DecTime.4.[i]
    TimeP[j+4]<- mydata$DecTime.5.[i]
    TimeP[j+5]<- mydata$DecTime.6.[i]
    TimeP[j+6]<- mydata$DecTime.7.[i]
    TimeP[j+7]<- mydata$DecTime.8.[i]
    TimeP[j+8]<- mydata$DecTime.9.[i]
    TimeP[j+9]<- mydata$DecTime.10.[i]
    TimeP[j+10]<- mydata$DecTime.11.[i]
    TimeP[j+11]<- mydata$DecTime.12.[i]
    TimeP[j+12]<- mydata$DecTime.13.[i]
    TimeP[j+13]<- mydata$DecTime.14.[i]
    TimeP[j+14]<- mydata$DecTime.15.[i]
    TimeP[j+15]<- mydata$DecTime.16.[i]
    TimeP[j+16]<- mydata$DecTime.17.[i]
    j<-j+17
    if(mydata$totper[i]>18){
      TimeP[j]<- mydata$DecTime.18.[i]
      j<-j+1
    }
    if(mydata$totper[i]>19){
      TimeP[j]<- mydata$DecTime.19.[i]
      j<-j+1
    }
    if(mydata$totper[i]>20){
      TimeP[j]<- mydata$DecTime.20.[i]
      j<-j+1
    }
    if(mydata$totper[i]>21){
      TimeP[j]<- mydata$DecTime.21.[i]
      j<-j+1
    }
    if(mydata$totper[i]>22){
      TimeP[j]<- mydata$DecTime.22.[i]
      j<-j+1
    }
    if(mydata$totper[i]>23){
      TimeP[j]<- mydata$DecTime.23.[i]
      j<-j+1
    }
    if(mydata$totper[i]>24){
      TimeP[j]<- mydata$DecTime.24.[i]
      j<-j+1
    }
    if(mydata$totper[i]>25){
      TimeP[j]<- mydata$DecTime.25.[i]
      j<-j+1
    }
  }
}

table(TimeC)
table(TimeF)
table(TimeA)
table(TimeP)

#Many obs...
pop1<-TimeC
pop2<-TimeF
pop3<-TimeA
pop4<-TimeP

# You have to turn the variable into a data frame to use ggplot
pop1.data <- data.frame(pop1)
pop2.data <- data.frame(pop2)
pop3.data <- data.frame(pop3)
pop4.data <- data.frame(pop4)

pop1.data$type <- NA
pop2.data$type <- NA
pop3.data$type <- NA
pop4.data$type <- NA
pop1.data$type <- 'Control'
pop2.data$type <- 'Fine'
pop3.data$type <- 'Assoc'
pop4.data$type <- 'Pun'


colnames(pop1.data) <- c("Time", "Condition")
colnames(pop2.data) <- c("Time", "Condition")
colnames(pop3.data) <- c("Time", "Condition")
colnames(pop4.data) <- c("Time", "Condition")

p1vsp2vsp3vsp4<- rbind(pop1.data, pop2.data, pop3.data, pop4.data)


plot1 <- ggplot(p1vsp2vsp3vsp4, aes(Time, fill=Condition,linetype=Condition)) + stat_ecdf(aes(colour=Condition)) + labs(x = "Time in Seconds", y = "Proportion")+ 
  theme_classic()+xlim(0,140)#+scale_color_manual(values=c('#000000','#E69F00'))+
  #annotation_custom(my_grob1)+xlim(0,100)+ylim(0,1)

mean(TimeC)
mean(TimeF)
mean(TimeA)
mean(TimeP)

t.test(TimeC,TimeF)
ks.test(TimeC,TimeF)

t.test(TimeC,TimeA)
ks.test(TimeC,TimeA)

t.test(TimeC,TimeP)
ks.test(TimeC,TimeP)

t.test(TimeF,TimeA)
ks.test(TimeF,TimeA)

t.test(TimeF,TimeP)
ks.test(TimeF,TimeP)


EarnFastR5C<-numeric()
EarnFastR5F<-numeric()
EarnFastR5A<-numeric()
EarnFastR5P<-numeric()

EarnSlowR5C<-numeric()
EarnSlowR5F<-numeric()
EarnSlowR5A<-numeric()
EarnSlowR5P<-numeric()
EarnAutoR5C<-numeric()
EarnAutoR5F<-numeric()
EarnAutoR5A<-numeric()
EarnAutoR5P<-numeric()

f<-1
s<-1
a<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.1.[i]==3){EarnFastR5C[f]<-mydata$ChoicePayoff.1.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.1.[i]==2){EarnSlowR5C[s]<-mydata$ChoicePayoff.1.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.1.[i]==1){EarnAutoR5C[a]<-mydata$ChoicePayoff.1.[i]
  a<-a+1}
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.2.[i]==3){EarnFastR5C[f]<-mydata$ChoicePayoff.2.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.2.[i]==2){EarnSlowR5C[s]<-mydata$ChoicePayoff.2.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.2.[i]==1){EarnAutoR5C[a]<-mydata$ChoicePayoff.2.[i]
  a<-a+1}
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.3.[i]==3){EarnFastR5C[f]<-mydata$ChoicePayoff.3.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.3.[i]==2){EarnSlowR5C[s]<-mydata$ChoicePayoff.3.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.3.[i]==1){EarnAutoR5C[a]<-mydata$ChoicePayoff.3.[i]
  a<-a+1}
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.4.[i]==3){EarnFastR5C[f]<-mydata$ChoicePayoff.4.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.4.[i]==2){EarnSlowR5C[s]<-mydata$ChoicePayoff.4.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.4.[i]==1){EarnAutoR5C[a]<-mydata$ChoicePayoff.4.[i]
  a<-a+1}
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.5.[i]==3){EarnFastR5C[f]<-mydata$ChoicePayoff.5.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.5.[i]==2){EarnSlowR5C[s]<-mydata$ChoicePayoff.5.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==1 & mydata$DrivingChoice.5.[i]==1){EarnAutoR5C[a]<-mydata$ChoicePayoff.5.[i]
  a<-a+1}
}


f<-1
s<-1
a<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.1.[i]==3){EarnFastR5F[f]<-mydata$ChoicePayoff.1.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.1.[i]==2){EarnSlowR5F[s]<-mydata$ChoicePayoff.1.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.1.[i]==1){EarnAutoR5F[a]<-mydata$ChoicePayoff.1.[i]
  a<-a+1}
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.2.[i]==3){EarnFastR5F[f]<-mydata$ChoicePayoff.2.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.2.[i]==2){EarnSlowR5F[s]<-mydata$ChoicePayoff.2.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.2.[i]==1){EarnAutoR5F[a]<-mydata$ChoicePayoff.2.[i]
  a<-a+1}
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.3.[i]==3){EarnFastR5F[f]<-mydata$ChoicePayoff.3.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.3.[i]==2){EarnSlowR5F[s]<-mydata$ChoicePayoff.3.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.3.[i]==1){EarnAutoR5F[a]<-mydata$ChoicePayoff.3.[i]
  a<-a+1}
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.4.[i]==3){EarnFastR5F[f]<-mydata$ChoicePayoff.4.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.4.[i]==2){EarnSlowR5F[s]<-mydata$ChoicePayoff.4.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.4.[i]==1){EarnAutoR5F[a]<-mydata$ChoicePayoff.4.[i]
  a<-a+1}
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.5.[i]==3){EarnFastR5F[f]<-mydata$ChoicePayoff.5.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.5.[i]==2){EarnSlowR5F[s]<-mydata$ChoicePayoff.5.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==2 & mydata$DrivingChoice.5.[i]==1){EarnAutoR5F[a]<-mydata$ChoicePayoff.5.[i]
  a<-a+1}
}

f<-1
s<-1
a<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.1.[i]==3){EarnFastR5A[f]<-mydata$ChoicePayoff.1.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.1.[i]==2){EarnSlowR5A[s]<-mydata$ChoicePayoff.1.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.1.[i]==1){EarnAutoR5A[a]<-mydata$ChoicePayoff.1.[i]
  a<-a+1}
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.2.[i]==3){EarnFastR5A[f]<-mydata$ChoicePayoff.2.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.2.[i]==2){EarnSlowR5A[s]<-mydata$ChoicePayoff.2.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.2.[i]==1){EarnAutoR5A[a]<-mydata$ChoicePayoff.2.[i]
  a<-a+1}
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.3.[i]==3){EarnFastR5A[f]<-mydata$ChoicePayoff.3.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.3.[i]==2){EarnSlowR5A[s]<-mydata$ChoicePayoff.3.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.3.[i]==1){EarnAutoR5A[a]<-mydata$ChoicePayoff.3.[i]
  a<-a+1}
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.4.[i]==3){EarnFastR5A[f]<-mydata$ChoicePayoff.4.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.4.[i]==2){EarnSlowR5A[s]<-mydata$ChoicePayoff.4.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.4.[i]==1){EarnAutoR5A[a]<-mydata$ChoicePayoff.4.[i]
  a<-a+1}
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.5.[i]==3){EarnFastR5A[f]<-mydata$ChoicePayoff.5.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.5.[i]==2){EarnSlowR5A[s]<-mydata$ChoicePayoff.5.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==3 & mydata$DrivingChoice.5.[i]==1){EarnAutoR5A[a]<-mydata$ChoicePayoff.5.[i]
  a<-a+1}
}


f<-1
s<-1
a<-1
for(i in 1:obs){
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.1.[i]==3){EarnFastR5P[f]<-mydata$ChoicePayoff.1.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.1.[i]==2){EarnSlowR5P[s]<-mydata$ChoicePayoff.1.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.1.[i]==1){EarnAutoR5P[a]<-mydata$ChoicePayoff.1.[i]
  a<-a+1}
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.2.[i]==3){EarnFastR5P[f]<-mydata$ChoicePayoff.2.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.2.[i]==2){EarnSlowR5P[s]<-mydata$ChoicePayoff.2.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.2.[i]==1){EarnAutoR5P[a]<-mydata$ChoicePayoff.2.[i]
  a<-a+1}
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.3.[i]==3){EarnFastR5P[f]<-mydata$ChoicePayoff.3.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.3.[i]==2){EarnSlowR5P[s]<-mydata$ChoicePayoff.3.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.3.[i]==1){EarnAutoR5P[a]<-mydata$ChoicePayoff.3.[i]
  a<-a+1}
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.4.[i]==3){EarnFastR5P[f]<-mydata$ChoicePayoff.4.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.4.[i]==2){EarnSlowR5P[s]<-mydata$ChoicePayoff.4.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.4.[i]==1){EarnAutoR5P[a]<-mydata$ChoicePayoff.4.[i]
  a<-a+1}
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.5.[i]==3){EarnFastR5P[f]<-mydata$ChoicePayoff.5.[i]
  f<-f+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.5.[i]==2){EarnSlowR5P[s]<-mydata$ChoicePayoff.5.[i]
  s<-s+1}  
  if(mydata$ExpType[i]==4 & mydata$DrivingChoice.5.[i]==1){EarnAutoR5P[a]<-mydata$ChoicePayoff.5.[i]
  a<-a+1}
}









table(EarnFastR5F)
table(EarnSlowR5F)
table(EarnAutoR5F)


mean(EarnSlowC)

t.test(EarnFastR5C,EarnFastR5F)

df <- data.frame(EarnFastR5C,EarnFastR5F,EarnFastR5A,EarnFastR5P)
df$dose <- as.factor(df$dose)








#OLD STUFF

#BEGIN OF GUESS PLOTS (Ends on line 878)
#Plot for Session 1
AvgGuessFastSess1<-numeric(25)
AvgGuessFastSess1[1]<-mean(mydata[mydata$Sess==1,"GuessFast.1."])
AvgGuessFastSess1[2]<-mean(mydata[mydata$Sess==1,"GuessFast.2."])
AvgGuessFastSess1[3]<-mean(mydata[mydata$Sess==1,"GuessFast.3."])
AvgGuessFastSess1[4]<-mean(mydata[mydata$Sess==1,"GuessFast.4."])
AvgGuessFastSess1[5]<-mean(mydata[mydata$Sess==1,"GuessFast.5."])
AvgGuessFastSess1[6]<-mean(mydata[mydata$Sess==1,"GuessFast.6."])
AvgGuessFastSess1[7]<-mean(mydata[mydata$Sess==1,"GuessFast.7."])
AvgGuessFastSess1[8]<-mean(mydata[mydata$Sess==1,"GuessFast.8."])
AvgGuessFastSess1[9]<-mean(mydata[mydata$Sess==1,"GuessFast.9."])
AvgGuessFastSess1[10]<-mean(mydata[mydata$Sess==1,"GuessFast.10."])
AvgGuessFastSess1[11]<-mean(mydata[mydata$Sess==1,"GuessFast.11."])
AvgGuessFastSess1[12]<-mean(mydata[mydata$Sess==1,"GuessFast.12."])
AvgGuessFastSess1[13]<-mean(mydata[mydata$Sess==1,"GuessFast.13."])
AvgGuessFastSess1[14]<-mean(mydata[mydata$Sess==1,"GuessFast.14."])
AvgGuessFastSess1[15]<-mean(mydata[mydata$Sess==1,"GuessFast.15."])
AvgGuessFastSess1[16]<-mean(mydata[mydata$Sess==1,"GuessFast.16."])
AvgGuessFastSess1[17]<-mean(mydata[mydata$Sess==1,"GuessFast.17."])
AvgGuessFastSess1[18]<-mean(mydata[mydata$Sess==1,"GuessFast.18."])
AvgGuessFastSess1[19]<-mean(mydata[mydata$Sess==1,"GuessFast.19."])
AvgGuessFastSess1[20]<-mean(mydata[mydata$Sess==1,"GuessFast.20."])
AvgGuessFastSess1[21]<-mean(mydata[mydata$Sess==1,"GuessFast.21."])
AvgGuessFastSess1[22]<-mean(mydata[mydata$Sess==1,"GuessFast.22."])
AvgGuessFastSess1[23]<-mean(mydata[mydata$Sess==1,"GuessFast.23."])
AvgGuessFastSess1[24]<-mean(mydata[mydata$Sess==1,"GuessFast.24."])
AvgGuessFastSess1[25]<-mean(mydata[mydata$Sess==1,"GuessFast.25."])
AvgGuessSlowSess1<-numeric(25)
AvgGuessSlowSess1[1]<-mean(mydata[mydata$Sess==1,"GuessSlow.1."])
AvgGuessSlowSess1[2]<-mean(mydata[mydata$Sess==1,"GuessSlow.2."])
AvgGuessSlowSess1[3]<-mean(mydata[mydata$Sess==1,"GuessSlow.3."])
AvgGuessSlowSess1[4]<-mean(mydata[mydata$Sess==1,"GuessSlow.4."])
AvgGuessSlowSess1[5]<-mean(mydata[mydata$Sess==1,"GuessSlow.5."])
AvgGuessSlowSess1[6]<-mean(mydata[mydata$Sess==1,"GuessSlow.6."])
AvgGuessSlowSess1[7]<-mean(mydata[mydata$Sess==1,"GuessSlow.7."])
AvgGuessSlowSess1[8]<-mean(mydata[mydata$Sess==1,"GuessSlow.8."])
AvgGuessSlowSess1[9]<-mean(mydata[mydata$Sess==1,"GuessSlow.9."])
AvgGuessSlowSess1[10]<-mean(mydata[mydata$Sess==1,"GuessSlow.10."])
AvgGuessSlowSess1[11]<-mean(mydata[mydata$Sess==1,"GuessSlow.11."])
AvgGuessSlowSess1[12]<-mean(mydata[mydata$Sess==1,"GuessSlow.12."])
AvgGuessSlowSess1[13]<-mean(mydata[mydata$Sess==1,"GuessSlow.13."])
AvgGuessSlowSess1[14]<-mean(mydata[mydata$Sess==1,"GuessSlow.14."])
AvgGuessSlowSess1[15]<-mean(mydata[mydata$Sess==1,"GuessSlow.15."])
AvgGuessSlowSess1[16]<-mean(mydata[mydata$Sess==1,"GuessSlow.16."])
AvgGuessSlowSess1[17]<-mean(mydata[mydata$Sess==1,"GuessSlow.17."])
AvgGuessSlowSess1[18]<-mean(mydata[mydata$Sess==1,"GuessSlow.18."])
AvgGuessSlowSess1[19]<-mean(mydata[mydata$Sess==1,"GuessSlow.19."])
AvgGuessSlowSess1[20]<-mean(mydata[mydata$Sess==1,"GuessSlow.20."])
AvgGuessSlowSess1[21]<-mean(mydata[mydata$Sess==1,"GuessSlow.21."])
AvgGuessSlowSess1[22]<-mean(mydata[mydata$Sess==1,"GuessSlow.22."])
AvgGuessSlowSess1[23]<-mean(mydata[mydata$Sess==1,"GuessSlow.23."])
AvgGuessSlowSess1[24]<-mean(mydata[mydata$Sess==1,"GuessSlow.24."])
AvgGuessSlowSess1[25]<-mean(mydata[mydata$Sess==1,"GuessSlow.25."])
AvgGuessAutoSess1<-numeric(25)
AvgGuessAutoSess1[1]<-mean(mydata[mydata$Sess==1,"GuessAuto.1."])
AvgGuessAutoSess1[2]<-mean(mydata[mydata$Sess==1,"GuessAuto.2."])
AvgGuessAutoSess1[3]<-mean(mydata[mydata$Sess==1,"GuessAuto.3."])
AvgGuessAutoSess1[4]<-mean(mydata[mydata$Sess==1,"GuessAuto.4."])
AvgGuessAutoSess1[5]<-mean(mydata[mydata$Sess==1,"GuessAuto.5."])
AvgGuessAutoSess1[6]<-mean(mydata[mydata$Sess==1,"GuessAuto.6."])
AvgGuessAutoSess1[7]<-mean(mydata[mydata$Sess==1,"GuessAuto.7."])
AvgGuessAutoSess1[8]<-mean(mydata[mydata$Sess==1,"GuessAuto.8."])
AvgGuessAutoSess1[9]<-mean(mydata[mydata$Sess==1,"GuessAuto.9."])
AvgGuessAutoSess1[10]<-mean(mydata[mydata$Sess==1,"GuessAuto.10."])
AvgGuessAutoSess1[11]<-mean(mydata[mydata$Sess==1,"GuessAuto.11."])
AvgGuessAutoSess1[12]<-mean(mydata[mydata$Sess==1,"GuessAuto.12."])
AvgGuessAutoSess1[13]<-mean(mydata[mydata$Sess==1,"GuessAuto.13."])
AvgGuessAutoSess1[14]<-mean(mydata[mydata$Sess==1,"GuessAuto.14."])
AvgGuessAutoSess1[15]<-mean(mydata[mydata$Sess==1,"GuessAuto.15."])
AvgGuessAutoSess1[16]<-mean(mydata[mydata$Sess==1,"GuessAuto.16."])
AvgGuessAutoSess1[17]<-mean(mydata[mydata$Sess==1,"GuessAuto.17."])
AvgGuessAutoSess1[18]<-mean(mydata[mydata$Sess==1,"GuessAuto.18."])
AvgGuessAutoSess1[19]<-mean(mydata[mydata$Sess==1,"GuessAuto.19."])
AvgGuessAutoSess1[20]<-mean(mydata[mydata$Sess==1,"GuessAuto.20."])
AvgGuessAutoSess1[21]<-mean(mydata[mydata$Sess==1,"GuessAuto.21."])
AvgGuessAutoSess1[22]<-mean(mydata[mydata$Sess==1,"GuessAuto.22."])
AvgGuessAutoSess1[23]<-mean(mydata[mydata$Sess==1,"GuessAuto.23."])
AvgGuessAutoSess1[24]<-mean(mydata[mydata$Sess==1,"GuessAuto.24."])
AvgGuessAutoSess1[25]<-mean(mydata[mydata$Sess==1,"GuessAuto.25."])

x<-c(1:25)
data <- data.frame(AvgGuessFastSess1, AvgGuessSlowSess1, AvgGuessAutoSess1)
data
Sess1Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess1, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess1, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess1, name = 'Auto', mode = 'lines+markers')%>%
layout(title = "Session 1 (Control)",
       xaxis = list(range = c(0, 25),title = "Round"),
       yaxis = list(range = c(0, 100),title = "Proportion"))
Sess1Plot


Auto <- AvgGuessAutoSess1
Slow <- AvgGuessSlowSess1
Fast <- AvgGuessFastSess1
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess1Tri <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess1Tri


Auto <- AvgGuessAutoSess1
Slow <- AvgGuessSlowSess1
Fast <- AvgGuessFastSess1
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess1Tri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 1 -  Control') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

#Plot for Session 2
AvgGuessFastSess2<-numeric(25)
AvgGuessFastSess2[1]<-mean(mydata[mydata$Sess==2,"GuessFast.1."])
AvgGuessFastSess2[2]<-mean(mydata[mydata$Sess==2,"GuessFast.2."])
AvgGuessFastSess2[3]<-mean(mydata[mydata$Sess==2,"GuessFast.3."])
AvgGuessFastSess2[4]<-mean(mydata[mydata$Sess==2,"GuessFast.4."])
AvgGuessFastSess2[5]<-mean(mydata[mydata$Sess==2,"GuessFast.5."])
AvgGuessFastSess2[6]<-mean(mydata[mydata$Sess==2,"GuessFast.6."])
AvgGuessFastSess2[7]<-mean(mydata[mydata$Sess==2,"GuessFast.7."])
AvgGuessFastSess2[8]<-mean(mydata[mydata$Sess==2,"GuessFast.8."])
AvgGuessFastSess2[9]<-mean(mydata[mydata$Sess==2,"GuessFast.9."])
AvgGuessFastSess2[10]<-mean(mydata[mydata$Sess==2,"GuessFast.10."])
AvgGuessFastSess2[11]<-mean(mydata[mydata$Sess==2,"GuessFast.11."])
AvgGuessFastSess2[12]<-mean(mydata[mydata$Sess==2,"GuessFast.12."])
AvgGuessFastSess2[13]<-mean(mydata[mydata$Sess==2,"GuessFast.13."])
AvgGuessFastSess2[14]<-mean(mydata[mydata$Sess==2,"GuessFast.14."])
AvgGuessFastSess2[15]<-mean(mydata[mydata$Sess==2,"GuessFast.15."])
AvgGuessFastSess2[16]<-mean(mydata[mydata$Sess==2,"GuessFast.16."])
AvgGuessFastSess2[17]<-mean(mydata[mydata$Sess==2,"GuessFast.17."])
AvgGuessFastSess2[18]<-mean(mydata[mydata$Sess==2,"GuessFast.18."])
AvgGuessFastSess2[19]<-mean(mydata[mydata$Sess==2,"GuessFast.19."])
AvgGuessFastSess2[20]<-mean(mydata[mydata$Sess==2,"GuessFast.20."])
AvgGuessFastSess2[21]<-mean(mydata[mydata$Sess==2,"GuessFast.21."])
AvgGuessFastSess2[22]<-mean(mydata[mydata$Sess==2,"GuessFast.22."])
AvgGuessFastSess2[23]<-mean(mydata[mydata$Sess==2,"GuessFast.23."])
AvgGuessFastSess2[24]<-mean(mydata[mydata$Sess==2,"GuessFast.24."])
AvgGuessFastSess2[25]<-mean(mydata[mydata$Sess==2,"GuessFast.25."])
AvgGuessSlowSess2<-numeric(25)
AvgGuessSlowSess2[1]<-mean(mydata[mydata$Sess==2,"GuessSlow.1."])
AvgGuessSlowSess2[2]<-mean(mydata[mydata$Sess==2,"GuessSlow.2."])
AvgGuessSlowSess2[3]<-mean(mydata[mydata$Sess==2,"GuessSlow.3."])
AvgGuessSlowSess2[4]<-mean(mydata[mydata$Sess==2,"GuessSlow.4."])
AvgGuessSlowSess2[5]<-mean(mydata[mydata$Sess==2,"GuessSlow.5."])
AvgGuessSlowSess2[6]<-mean(mydata[mydata$Sess==2,"GuessSlow.6."])
AvgGuessSlowSess2[7]<-mean(mydata[mydata$Sess==2,"GuessSlow.7."])
AvgGuessSlowSess2[8]<-mean(mydata[mydata$Sess==2,"GuessSlow.8."])
AvgGuessSlowSess2[9]<-mean(mydata[mydata$Sess==2,"GuessSlow.9."])
AvgGuessSlowSess2[10]<-mean(mydata[mydata$Sess==2,"GuessSlow.10."])
AvgGuessSlowSess2[11]<-mean(mydata[mydata$Sess==2,"GuessSlow.11."])
AvgGuessSlowSess2[12]<-mean(mydata[mydata$Sess==2,"GuessSlow.12."])
AvgGuessSlowSess2[13]<-mean(mydata[mydata$Sess==2,"GuessSlow.13."])
AvgGuessSlowSess2[14]<-mean(mydata[mydata$Sess==2,"GuessSlow.14."])
AvgGuessSlowSess2[15]<-mean(mydata[mydata$Sess==2,"GuessSlow.15."])
AvgGuessSlowSess2[16]<-mean(mydata[mydata$Sess==2,"GuessSlow.16."])
AvgGuessSlowSess2[17]<-mean(mydata[mydata$Sess==2,"GuessSlow.17."])
AvgGuessSlowSess2[18]<-mean(mydata[mydata$Sess==2,"GuessSlow.18."])
AvgGuessSlowSess2[19]<-mean(mydata[mydata$Sess==2,"GuessSlow.19."])
AvgGuessSlowSess2[20]<-mean(mydata[mydata$Sess==2,"GuessSlow.20."])
AvgGuessSlowSess2[21]<-mean(mydata[mydata$Sess==2,"GuessSlow.21."])
AvgGuessSlowSess2[22]<-mean(mydata[mydata$Sess==2,"GuessSlow.22."])
AvgGuessSlowSess2[23]<-mean(mydata[mydata$Sess==2,"GuessSlow.23."])
AvgGuessSlowSess2[24]<-mean(mydata[mydata$Sess==2,"GuessSlow.24."])
AvgGuessSlowSess2[25]<-mean(mydata[mydata$Sess==2,"GuessSlow.25."])
AvgGuessAutoSess2<-numeric(25)
AvgGuessAutoSess2[1]<-mean(mydata[mydata$Sess==2,"GuessAuto.1."])
AvgGuessAutoSess2[2]<-mean(mydata[mydata$Sess==2,"GuessAuto.2."])
AvgGuessAutoSess2[3]<-mean(mydata[mydata$Sess==2,"GuessAuto.3."])
AvgGuessAutoSess2[4]<-mean(mydata[mydata$Sess==2,"GuessAuto.4."])
AvgGuessAutoSess2[5]<-mean(mydata[mydata$Sess==2,"GuessAuto.5."])
AvgGuessAutoSess2[6]<-mean(mydata[mydata$Sess==2,"GuessAuto.6."])
AvgGuessAutoSess2[7]<-mean(mydata[mydata$Sess==2,"GuessAuto.7."])
AvgGuessAutoSess2[8]<-mean(mydata[mydata$Sess==2,"GuessAuto.8."])
AvgGuessAutoSess2[9]<-mean(mydata[mydata$Sess==2,"GuessAuto.9."])
AvgGuessAutoSess2[10]<-mean(mydata[mydata$Sess==2,"GuessAuto.10."])
AvgGuessAutoSess2[11]<-mean(mydata[mydata$Sess==2,"GuessAuto.11."])
AvgGuessAutoSess2[12]<-mean(mydata[mydata$Sess==2,"GuessAuto.12."])
AvgGuessAutoSess2[13]<-mean(mydata[mydata$Sess==2,"GuessAuto.13."])
AvgGuessAutoSess2[14]<-mean(mydata[mydata$Sess==2,"GuessAuto.14."])
AvgGuessAutoSess2[15]<-mean(mydata[mydata$Sess==2,"GuessAuto.15."])
AvgGuessAutoSess2[16]<-mean(mydata[mydata$Sess==2,"GuessAuto.16."])
AvgGuessAutoSess2[17]<-mean(mydata[mydata$Sess==2,"GuessAuto.17."])
AvgGuessAutoSess2[18]<-mean(mydata[mydata$Sess==2,"GuessAuto.18."])
AvgGuessAutoSess2[19]<-mean(mydata[mydata$Sess==2,"GuessAuto.19."])
AvgGuessAutoSess2[20]<-mean(mydata[mydata$Sess==2,"GuessAuto.20."])
AvgGuessAutoSess2[21]<-mean(mydata[mydata$Sess==2,"GuessAuto.21."])
AvgGuessAutoSess2[22]<-mean(mydata[mydata$Sess==2,"GuessAuto.22."])
AvgGuessAutoSess2[23]<-mean(mydata[mydata$Sess==2,"GuessAuto.23."])
AvgGuessAutoSess2[24]<-mean(mydata[mydata$Sess==2,"GuessAuto.24."])
AvgGuessAutoSess2[25]<-mean(mydata[mydata$Sess==2,"GuessAuto.25."])

data <- data.frame(AvgGuessFastSess2, AvgGuessSlowSess2, AvgGuessAutoSess2)
Sess2Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess2, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess2, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess2, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 2 (Compulsion)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess2Plot

Auto <- AvgGuessAutoSess2
Slow <- AvgGuessSlowSess2
Fast <- AvgGuessFastSess2
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess2Tri <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess2Tri

Auto <- AvgGuessAutoSess2
Slow <- AvgGuessSlowSess2
Fast <- AvgGuessFastSess2
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess2Tri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 2 -  Compulsion') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

#Plot for Session 3
AvgGuessFastSess3<-numeric(25)
AvgGuessFastSess3[1]<-mean(mydata[mydata$Sess==3,"GuessFast.1."])
AvgGuessFastSess3[2]<-mean(mydata[mydata$Sess==3,"GuessFast.2."])
AvgGuessFastSess3[3]<-mean(mydata[mydata$Sess==3,"GuessFast.3."])
AvgGuessFastSess3[4]<-mean(mydata[mydata$Sess==3,"GuessFast.4."])
AvgGuessFastSess3[5]<-mean(mydata[mydata$Sess==3,"GuessFast.5."])
AvgGuessFastSess3[6]<-mean(mydata[mydata$Sess==3,"GuessFast.6."])
AvgGuessFastSess3[7]<-mean(mydata[mydata$Sess==3,"GuessFast.7."])
AvgGuessFastSess3[8]<-mean(mydata[mydata$Sess==3,"GuessFast.8."])
AvgGuessFastSess3[9]<-mean(mydata[mydata$Sess==3,"GuessFast.9."])
AvgGuessFastSess3[10]<-mean(mydata[mydata$Sess==3,"GuessFast.10."])
AvgGuessFastSess3[11]<-mean(mydata[mydata$Sess==3,"GuessFast.11."])
AvgGuessFastSess3[12]<-mean(mydata[mydata$Sess==3,"GuessFast.12."])
AvgGuessFastSess3[13]<-mean(mydata[mydata$Sess==3,"GuessFast.13."])
AvgGuessFastSess3[14]<-mean(mydata[mydata$Sess==3,"GuessFast.14."])
AvgGuessFastSess3[15]<-mean(mydata[mydata$Sess==3,"GuessFast.15."])
AvgGuessFastSess3[16]<-mean(mydata[mydata$Sess==3,"GuessFast.16."])
AvgGuessFastSess3[17]<-mean(mydata[mydata$Sess==3,"GuessFast.17."])
AvgGuessFastSess3[18]<-mean(mydata[mydata$Sess==3,"GuessFast.18."])
AvgGuessFastSess3[19]<-mean(mydata[mydata$Sess==3,"GuessFast.19."])
AvgGuessFastSess3[20]<-mean(mydata[mydata$Sess==3,"GuessFast.20."])
AvgGuessFastSess3[21]<-mean(mydata[mydata$Sess==3,"GuessFast.21."])
AvgGuessFastSess3[22]<-mean(mydata[mydata$Sess==3,"GuessFast.22."])
AvgGuessFastSess3[23]<-mean(mydata[mydata$Sess==3,"GuessFast.23."])
AvgGuessFastSess3[24]<-mean(mydata[mydata$Sess==3,"GuessFast.24."])
AvgGuessFastSess3[25]<-mean(mydata[mydata$Sess==3,"GuessFast.25."])
AvgGuessSlowSess3<-numeric(25)
AvgGuessSlowSess3[1]<-mean(mydata[mydata$Sess==3,"GuessSlow.1."])
AvgGuessSlowSess3[2]<-mean(mydata[mydata$Sess==3,"GuessSlow.2."])
AvgGuessSlowSess3[3]<-mean(mydata[mydata$Sess==3,"GuessSlow.3."])
AvgGuessSlowSess3[4]<-mean(mydata[mydata$Sess==3,"GuessSlow.4."])
AvgGuessSlowSess3[5]<-mean(mydata[mydata$Sess==3,"GuessSlow.5."])
AvgGuessSlowSess3[6]<-mean(mydata[mydata$Sess==3,"GuessSlow.6."])
AvgGuessSlowSess3[7]<-mean(mydata[mydata$Sess==3,"GuessSlow.7."])
AvgGuessSlowSess3[8]<-mean(mydata[mydata$Sess==3,"GuessSlow.8."])
AvgGuessSlowSess3[9]<-mean(mydata[mydata$Sess==3,"GuessSlow.9."])
AvgGuessSlowSess3[10]<-mean(mydata[mydata$Sess==3,"GuessSlow.10."])
AvgGuessSlowSess3[11]<-mean(mydata[mydata$Sess==3,"GuessSlow.11."])
AvgGuessSlowSess3[12]<-mean(mydata[mydata$Sess==3,"GuessSlow.12."])
AvgGuessSlowSess3[13]<-mean(mydata[mydata$Sess==3,"GuessSlow.13."])
AvgGuessSlowSess3[14]<-mean(mydata[mydata$Sess==3,"GuessSlow.14."])
AvgGuessSlowSess3[15]<-mean(mydata[mydata$Sess==3,"GuessSlow.15."])
AvgGuessSlowSess3[16]<-mean(mydata[mydata$Sess==3,"GuessSlow.16."])
AvgGuessSlowSess3[17]<-mean(mydata[mydata$Sess==3,"GuessSlow.17."])
AvgGuessSlowSess3[18]<-mean(mydata[mydata$Sess==3,"GuessSlow.18."])
AvgGuessSlowSess3[19]<-mean(mydata[mydata$Sess==3,"GuessSlow.19."])
AvgGuessSlowSess3[20]<-mean(mydata[mydata$Sess==3,"GuessSlow.20."])
AvgGuessSlowSess3[21]<-mean(mydata[mydata$Sess==3,"GuessSlow.21."])
AvgGuessSlowSess3[22]<-mean(mydata[mydata$Sess==3,"GuessSlow.22."])
AvgGuessSlowSess3[23]<-mean(mydata[mydata$Sess==3,"GuessSlow.23."])
AvgGuessSlowSess3[24]<-mean(mydata[mydata$Sess==3,"GuessSlow.24."])
AvgGuessSlowSess3[25]<-mean(mydata[mydata$Sess==3,"GuessSlow.25."])
AvgGuessAutoSess3<-numeric(25)
AvgGuessAutoSess3[1]<-mean(mydata[mydata$Sess==3,"GuessAuto.1."])
AvgGuessAutoSess3[2]<-mean(mydata[mydata$Sess==3,"GuessAuto.2."])
AvgGuessAutoSess3[3]<-mean(mydata[mydata$Sess==3,"GuessAuto.3."])
AvgGuessAutoSess3[4]<-mean(mydata[mydata$Sess==3,"GuessAuto.4."])
AvgGuessAutoSess3[5]<-mean(mydata[mydata$Sess==3,"GuessAuto.5."])
AvgGuessAutoSess3[6]<-mean(mydata[mydata$Sess==3,"GuessAuto.6."])
AvgGuessAutoSess3[7]<-mean(mydata[mydata$Sess==3,"GuessAuto.7."])
AvgGuessAutoSess3[8]<-mean(mydata[mydata$Sess==3,"GuessAuto.8."])
AvgGuessAutoSess3[9]<-mean(mydata[mydata$Sess==3,"GuessAuto.9."])
AvgGuessAutoSess3[10]<-mean(mydata[mydata$Sess==3,"GuessAuto.10."])
AvgGuessAutoSess3[11]<-mean(mydata[mydata$Sess==3,"GuessAuto.11."])
AvgGuessAutoSess3[12]<-mean(mydata[mydata$Sess==3,"GuessAuto.12."])
AvgGuessAutoSess3[13]<-mean(mydata[mydata$Sess==3,"GuessAuto.13."])
AvgGuessAutoSess3[14]<-mean(mydata[mydata$Sess==3,"GuessAuto.14."])
AvgGuessAutoSess3[15]<-mean(mydata[mydata$Sess==3,"GuessAuto.15."])
AvgGuessAutoSess3[16]<-mean(mydata[mydata$Sess==3,"GuessAuto.16."])
AvgGuessAutoSess3[17]<-mean(mydata[mydata$Sess==3,"GuessAuto.17."])
AvgGuessAutoSess3[18]<-mean(mydata[mydata$Sess==3,"GuessAuto.18."])
AvgGuessAutoSess3[19]<-mean(mydata[mydata$Sess==3,"GuessAuto.19."])
AvgGuessAutoSess3[20]<-mean(mydata[mydata$Sess==3,"GuessAuto.20."])
AvgGuessAutoSess3[21]<-mean(mydata[mydata$Sess==3,"GuessAuto.21."])
AvgGuessAutoSess3[22]<-mean(mydata[mydata$Sess==3,"GuessAuto.22."])
AvgGuessAutoSess3[23]<-mean(mydata[mydata$Sess==3,"GuessAuto.23."])
AvgGuessAutoSess3[24]<-mean(mydata[mydata$Sess==3,"GuessAuto.24."])
AvgGuessAutoSess3[25]<-mean(mydata[mydata$Sess==3,"GuessAuto.25."])

data <- data.frame(AvgGuessFastSess3, AvgGuessSlowSess3, AvgGuessAutoSess3)
Sess3Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess3, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess3, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess3, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 3 (Association)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess3Plot

Auto <- AvgGuessAutoSess3
Slow <- AvgGuessSlowSess3
Fast <- AvgGuessFastSess3
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess3Tri <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess3Tri

Auto <- AvgGuessAutoSess3
Slow <- AvgGuessSlowSess3
Fast <- AvgGuessFastSess3
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess3Tri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 3 -  Association') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

#Plot for Session 4
AvgGuessFastSess4<-numeric(25)
AvgGuessFastSess4[1]<-mean(mydata[mydata$Sess==4,"GuessFast.1."])
AvgGuessFastSess4[2]<-mean(mydata[mydata$Sess==4,"GuessFast.2."])
AvgGuessFastSess4[3]<-mean(mydata[mydata$Sess==4,"GuessFast.3."])
AvgGuessFastSess4[4]<-mean(mydata[mydata$Sess==4,"GuessFast.4."])
AvgGuessFastSess4[5]<-mean(mydata[mydata$Sess==4,"GuessFast.5."])
AvgGuessFastSess4[6]<-mean(mydata[mydata$Sess==4,"GuessFast.6."])
AvgGuessFastSess4[7]<-mean(mydata[mydata$Sess==4,"GuessFast.7."])
AvgGuessFastSess4[8]<-mean(mydata[mydata$Sess==4,"GuessFast.8."])
AvgGuessFastSess4[9]<-mean(mydata[mydata$Sess==4,"GuessFast.9."])
AvgGuessFastSess4[10]<-mean(mydata[mydata$Sess==4,"GuessFast.10."])
AvgGuessFastSess4[11]<-mean(mydata[mydata$Sess==4,"GuessFast.11."])
AvgGuessFastSess4[12]<-mean(mydata[mydata$Sess==4,"GuessFast.12."])
AvgGuessFastSess4[13]<-mean(mydata[mydata$Sess==4,"GuessFast.13."])
AvgGuessFastSess4[14]<-mean(mydata[mydata$Sess==4,"GuessFast.14."])
AvgGuessFastSess4[15]<-mean(mydata[mydata$Sess==4,"GuessFast.15."])
AvgGuessFastSess4[16]<-mean(mydata[mydata$Sess==4,"GuessFast.16."])
AvgGuessFastSess4[17]<-mean(mydata[mydata$Sess==4,"GuessFast.17."])
AvgGuessFastSess4[18]<-mean(mydata[mydata$Sess==4,"GuessFast.18."])
AvgGuessFastSess4[19]<-mean(mydata[mydata$Sess==4,"GuessFast.19."])
AvgGuessFastSess4[20]<-mean(mydata[mydata$Sess==4,"GuessFast.20."])
AvgGuessFastSess4[21]<-mean(mydata[mydata$Sess==4,"GuessFast.21."])
AvgGuessFastSess4[22]<-mean(mydata[mydata$Sess==4,"GuessFast.22."])
AvgGuessFastSess4[23]<-mean(mydata[mydata$Sess==4,"GuessFast.23."])
AvgGuessFastSess4[24]<-mean(mydata[mydata$Sess==4,"GuessFast.24."])
AvgGuessFastSess4[25]<-mean(mydata[mydata$Sess==4,"GuessFast.25."])
AvgGuessSlowSess4<-numeric(25)
AvgGuessSlowSess4[1]<-mean(mydata[mydata$Sess==4,"GuessSlow.1."])
AvgGuessSlowSess4[2]<-mean(mydata[mydata$Sess==4,"GuessSlow.2."])
AvgGuessSlowSess4[3]<-mean(mydata[mydata$Sess==4,"GuessSlow.3."])
AvgGuessSlowSess4[4]<-mean(mydata[mydata$Sess==4,"GuessSlow.4."])
AvgGuessSlowSess4[5]<-mean(mydata[mydata$Sess==4,"GuessSlow.5."])
AvgGuessSlowSess4[6]<-mean(mydata[mydata$Sess==4,"GuessSlow.6."])
AvgGuessSlowSess4[7]<-mean(mydata[mydata$Sess==4,"GuessSlow.7."])
AvgGuessSlowSess4[8]<-mean(mydata[mydata$Sess==4,"GuessSlow.8."])
AvgGuessSlowSess4[9]<-mean(mydata[mydata$Sess==4,"GuessSlow.9."])
AvgGuessSlowSess4[10]<-mean(mydata[mydata$Sess==4,"GuessSlow.10."])
AvgGuessSlowSess4[11]<-mean(mydata[mydata$Sess==4,"GuessSlow.11."])
AvgGuessSlowSess4[12]<-mean(mydata[mydata$Sess==4,"GuessSlow.12."])
AvgGuessSlowSess4[13]<-mean(mydata[mydata$Sess==4,"GuessSlow.13."])
AvgGuessSlowSess4[14]<-mean(mydata[mydata$Sess==4,"GuessSlow.14."])
AvgGuessSlowSess4[15]<-mean(mydata[mydata$Sess==4,"GuessSlow.15."])
AvgGuessSlowSess4[16]<-mean(mydata[mydata$Sess==4,"GuessSlow.16."])
AvgGuessSlowSess4[17]<-mean(mydata[mydata$Sess==4,"GuessSlow.17."])
AvgGuessSlowSess4[18]<-mean(mydata[mydata$Sess==4,"GuessSlow.18."])
AvgGuessSlowSess4[19]<-mean(mydata[mydata$Sess==4,"GuessSlow.19."])
AvgGuessSlowSess4[20]<-mean(mydata[mydata$Sess==4,"GuessSlow.20."])
AvgGuessSlowSess4[21]<-mean(mydata[mydata$Sess==4,"GuessSlow.21."])
AvgGuessSlowSess4[22]<-mean(mydata[mydata$Sess==4,"GuessSlow.22."])
AvgGuessSlowSess4[23]<-mean(mydata[mydata$Sess==4,"GuessSlow.23."])
AvgGuessSlowSess4[24]<-mean(mydata[mydata$Sess==4,"GuessSlow.24."])
AvgGuessSlowSess4[25]<-mean(mydata[mydata$Sess==4,"GuessSlow.25."])
AvgGuessAutoSess4<-numeric(25)
AvgGuessAutoSess4[1]<-mean(mydata[mydata$Sess==4,"GuessAuto.1."])
AvgGuessAutoSess4[2]<-mean(mydata[mydata$Sess==4,"GuessAuto.2."])
AvgGuessAutoSess4[3]<-mean(mydata[mydata$Sess==4,"GuessAuto.3."])
AvgGuessAutoSess4[4]<-mean(mydata[mydata$Sess==4,"GuessAuto.4."])
AvgGuessAutoSess4[5]<-mean(mydata[mydata$Sess==4,"GuessAuto.5."])
AvgGuessAutoSess4[6]<-mean(mydata[mydata$Sess==4,"GuessAuto.6."])
AvgGuessAutoSess4[7]<-mean(mydata[mydata$Sess==4,"GuessAuto.7."])
AvgGuessAutoSess4[8]<-mean(mydata[mydata$Sess==4,"GuessAuto.8."])
AvgGuessAutoSess4[9]<-mean(mydata[mydata$Sess==4,"GuessAuto.9."])
AvgGuessAutoSess4[10]<-mean(mydata[mydata$Sess==4,"GuessAuto.10."])
AvgGuessAutoSess4[11]<-mean(mydata[mydata$Sess==4,"GuessAuto.11."])
AvgGuessAutoSess4[12]<-mean(mydata[mydata$Sess==4,"GuessAuto.12."])
AvgGuessAutoSess4[13]<-mean(mydata[mydata$Sess==4,"GuessAuto.13."])
AvgGuessAutoSess4[14]<-mean(mydata[mydata$Sess==4,"GuessAuto.14."])
AvgGuessAutoSess4[15]<-mean(mydata[mydata$Sess==4,"GuessAuto.15."])
AvgGuessAutoSess4[16]<-mean(mydata[mydata$Sess==4,"GuessAuto.16."])
AvgGuessAutoSess4[17]<-mean(mydata[mydata$Sess==4,"GuessAuto.17."])
AvgGuessAutoSess4[18]<-mean(mydata[mydata$Sess==4,"GuessAuto.18."])
AvgGuessAutoSess4[19]<-mean(mydata[mydata$Sess==4,"GuessAuto.19."])
AvgGuessAutoSess4[20]<-mean(mydata[mydata$Sess==4,"GuessAuto.20."])
AvgGuessAutoSess4[21]<-mean(mydata[mydata$Sess==4,"GuessAuto.21."])
AvgGuessAutoSess4[22]<-mean(mydata[mydata$Sess==4,"GuessAuto.22."])
AvgGuessAutoSess4[23]<-mean(mydata[mydata$Sess==4,"GuessAuto.23."])
AvgGuessAutoSess4[24]<-mean(mydata[mydata$Sess==4,"GuessAuto.24."])
AvgGuessAutoSess4[25]<-mean(mydata[mydata$Sess==4,"GuessAuto.25."])

data <- data.frame(AvgGuessFastSess4, AvgGuessSlowSess4, AvgGuessAutoSess4)
Sess4Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess4, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess4, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess4, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 4 (Association)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess4Plot


Auto <- AvgGuessAutoSess4
Slow <- AvgGuessSlowSess4
Fast <- AvgGuessFastSess4
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess4Tri <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess4Tri

Auto <- AvgGuessAutoSess4
Slow <- AvgGuessSlowSess4
Fast <- AvgGuessFastSess4
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess4Tri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 4 -  Association') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

#Plot for Session 5
AvgGuessFastSess5<-numeric(25)
AvgGuessFastSess5[1]<-mean(mydata[mydata$Sess==5,"GuessFast.1."])
AvgGuessFastSess5[2]<-mean(mydata[mydata$Sess==5,"GuessFast.2."])
AvgGuessFastSess5[3]<-mean(mydata[mydata$Sess==5,"GuessFast.3."])
AvgGuessFastSess5[4]<-mean(mydata[mydata$Sess==5,"GuessFast.4."])
AvgGuessFastSess5[5]<-mean(mydata[mydata$Sess==5,"GuessFast.5."])
AvgGuessFastSess5[6]<-mean(mydata[mydata$Sess==5,"GuessFast.6."])
AvgGuessFastSess5[7]<-mean(mydata[mydata$Sess==5,"GuessFast.7."])
AvgGuessFastSess5[8]<-mean(mydata[mydata$Sess==5,"GuessFast.8."])
AvgGuessFastSess5[9]<-mean(mydata[mydata$Sess==5,"GuessFast.9."])
AvgGuessFastSess5[10]<-mean(mydata[mydata$Sess==5,"GuessFast.10."])
AvgGuessFastSess5[11]<-mean(mydata[mydata$Sess==5,"GuessFast.11."])
AvgGuessFastSess5[12]<-mean(mydata[mydata$Sess==5,"GuessFast.12."])
AvgGuessFastSess5[13]<-mean(mydata[mydata$Sess==5,"GuessFast.13."])
AvgGuessFastSess5[14]<-mean(mydata[mydata$Sess==5,"GuessFast.14."])
AvgGuessFastSess5[15]<-mean(mydata[mydata$Sess==5,"GuessFast.15."])
AvgGuessFastSess5[16]<-mean(mydata[mydata$Sess==5,"GuessFast.16."])
AvgGuessFastSess5[17]<-mean(mydata[mydata$Sess==5,"GuessFast.17."])
AvgGuessFastSess5[18]<-mean(mydata[mydata$Sess==5,"GuessFast.18."])
AvgGuessFastSess5[19]<-mean(mydata[mydata$Sess==5,"GuessFast.19."])
AvgGuessFastSess5[20]<-mean(mydata[mydata$Sess==5,"GuessFast.20."])
AvgGuessFastSess5[21]<-mean(mydata[mydata$Sess==5,"GuessFast.21."])
AvgGuessFastSess5[22]<-mean(mydata[mydata$Sess==5,"GuessFast.22."])
AvgGuessFastSess5[23]<-mean(mydata[mydata$Sess==5,"GuessFast.23."])
AvgGuessFastSess5[24]<-mean(mydata[mydata$Sess==5,"GuessFast.24."])
AvgGuessFastSess5[25]<-mean(mydata[mydata$Sess==5,"GuessFast.25."])
AvgGuessSlowSess5<-numeric(25)
AvgGuessSlowSess5[1]<-mean(mydata[mydata$Sess==5,"GuessSlow.1."])
AvgGuessSlowSess5[2]<-mean(mydata[mydata$Sess==5,"GuessSlow.2."])
AvgGuessSlowSess5[3]<-mean(mydata[mydata$Sess==5,"GuessSlow.3."])
AvgGuessSlowSess5[4]<-mean(mydata[mydata$Sess==5,"GuessSlow.4."])
AvgGuessSlowSess5[5]<-mean(mydata[mydata$Sess==5,"GuessSlow.5."])
AvgGuessSlowSess5[6]<-mean(mydata[mydata$Sess==5,"GuessSlow.6."])
AvgGuessSlowSess5[7]<-mean(mydata[mydata$Sess==5,"GuessSlow.7."])
AvgGuessSlowSess5[8]<-mean(mydata[mydata$Sess==5,"GuessSlow.8."])
AvgGuessSlowSess5[9]<-mean(mydata[mydata$Sess==5,"GuessSlow.9."])
AvgGuessSlowSess5[10]<-mean(mydata[mydata$Sess==5,"GuessSlow.10."])
AvgGuessSlowSess5[11]<-mean(mydata[mydata$Sess==5,"GuessSlow.11."])
AvgGuessSlowSess5[12]<-mean(mydata[mydata$Sess==5,"GuessSlow.12."])
AvgGuessSlowSess5[13]<-mean(mydata[mydata$Sess==5,"GuessSlow.13."])
AvgGuessSlowSess5[14]<-mean(mydata[mydata$Sess==5,"GuessSlow.14."])
AvgGuessSlowSess5[15]<-mean(mydata[mydata$Sess==5,"GuessSlow.15."])
AvgGuessSlowSess5[16]<-mean(mydata[mydata$Sess==5,"GuessSlow.16."])
AvgGuessSlowSess5[17]<-mean(mydata[mydata$Sess==5,"GuessSlow.17."])
AvgGuessSlowSess5[18]<-mean(mydata[mydata$Sess==5,"GuessSlow.18."])
AvgGuessSlowSess5[19]<-mean(mydata[mydata$Sess==5,"GuessSlow.19."])
AvgGuessSlowSess5[20]<-mean(mydata[mydata$Sess==5,"GuessSlow.20."])
AvgGuessSlowSess5[21]<-mean(mydata[mydata$Sess==5,"GuessSlow.21."])
AvgGuessSlowSess5[22]<-mean(mydata[mydata$Sess==5,"GuessSlow.22."])
AvgGuessSlowSess5[23]<-mean(mydata[mydata$Sess==5,"GuessSlow.23."])
AvgGuessSlowSess5[24]<-mean(mydata[mydata$Sess==5,"GuessSlow.24."])
AvgGuessSlowSess5[25]<-mean(mydata[mydata$Sess==5,"GuessSlow.25."])
AvgGuessAutoSess5<-numeric(25)
AvgGuessAutoSess5[1]<-mean(mydata[mydata$Sess==5,"GuessAuto.1."])
AvgGuessAutoSess5[2]<-mean(mydata[mydata$Sess==5,"GuessAuto.2."])
AvgGuessAutoSess5[3]<-mean(mydata[mydata$Sess==5,"GuessAuto.3."])
AvgGuessAutoSess5[4]<-mean(mydata[mydata$Sess==5,"GuessAuto.4."])
AvgGuessAutoSess5[5]<-mean(mydata[mydata$Sess==5,"GuessAuto.5."])
AvgGuessAutoSess5[6]<-mean(mydata[mydata$Sess==5,"GuessAuto.6."])
AvgGuessAutoSess5[7]<-mean(mydata[mydata$Sess==5,"GuessAuto.7."])
AvgGuessAutoSess5[8]<-mean(mydata[mydata$Sess==5,"GuessAuto.8."])
AvgGuessAutoSess5[9]<-mean(mydata[mydata$Sess==5,"GuessAuto.9."])
AvgGuessAutoSess5[10]<-mean(mydata[mydata$Sess==5,"GuessAuto.10."])
AvgGuessAutoSess5[11]<-mean(mydata[mydata$Sess==5,"GuessAuto.11."])
AvgGuessAutoSess5[12]<-mean(mydata[mydata$Sess==5,"GuessAuto.12."])
AvgGuessAutoSess5[13]<-mean(mydata[mydata$Sess==5,"GuessAuto.13."])
AvgGuessAutoSess5[14]<-mean(mydata[mydata$Sess==5,"GuessAuto.14."])
AvgGuessAutoSess5[15]<-mean(mydata[mydata$Sess==5,"GuessAuto.15."])
AvgGuessAutoSess5[16]<-mean(mydata[mydata$Sess==5,"GuessAuto.16."])
AvgGuessAutoSess5[17]<-mean(mydata[mydata$Sess==5,"GuessAuto.17."])
AvgGuessAutoSess5[18]<-mean(mydata[mydata$Sess==5,"GuessAuto.18."])
AvgGuessAutoSess5[19]<-mean(mydata[mydata$Sess==5,"GuessAuto.19."])
AvgGuessAutoSess5[20]<-mean(mydata[mydata$Sess==5,"GuessAuto.20."])
AvgGuessAutoSess5[21]<-mean(mydata[mydata$Sess==5,"GuessAuto.21."])
AvgGuessAutoSess5[22]<-mean(mydata[mydata$Sess==5,"GuessAuto.22."])
AvgGuessAutoSess5[23]<-mean(mydata[mydata$Sess==5,"GuessAuto.23."])
AvgGuessAutoSess5[24]<-mean(mydata[mydata$Sess==5,"GuessAuto.24."])
AvgGuessAutoSess5[25]<-mean(mydata[mydata$Sess==5,"GuessAuto.25."])

data <- data.frame(AvgGuessFastSess5, AvgGuessSlowSess5, AvgGuessAutoSess5)
Sess5Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess5, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess5, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess5, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 5 (Compulsion)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess5Plot

Auto <- AvgGuessAutoSess5
Slow <- AvgGuessSlowSess5
Fast <- AvgGuessFastSess5
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess5Tri <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess5Tri


Auto <- AvgGuessAutoSess5
Slow <- AvgGuessSlowSess5
Fast <- AvgGuessFastSess5
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess5Tri2 <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 5 - Compulsion') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess5Tri2









#Plot for Session 24 (Punishment2.5)
AvgGuessFastSess24<-numeric(25)
AvgGuessFastSess24[1]<-mean(mydata[mydata$Sess==24,"GuessFast.1."])
AvgGuessFastSess24[2]<-mean(mydata[mydata$Sess==24,"GuessFast.2."])
AvgGuessFastSess24[3]<-mean(mydata[mydata$Sess==24,"GuessFast.3."])
AvgGuessFastSess24[4]<-mean(mydata[mydata$Sess==24,"GuessFast.4."])
AvgGuessFastSess24[5]<-mean(mydata[mydata$Sess==24,"GuessFast.5."])
AvgGuessFastSess24[6]<-mean(mydata[mydata$Sess==24,"GuessFast.6."])
AvgGuessFastSess24[7]<-mean(mydata[mydata$Sess==24,"GuessFast.7."])
AvgGuessFastSess24[8]<-mean(mydata[mydata$Sess==24,"GuessFast.8."])
AvgGuessFastSess24[9]<-mean(mydata[mydata$Sess==24,"GuessFast.9."])
AvgGuessFastSess24[10]<-mean(mydata[mydata$Sess==24,"GuessFast.10."])
AvgGuessFastSess24[11]<-mean(mydata[mydata$Sess==24,"GuessFast.11."])
AvgGuessFastSess24[12]<-mean(mydata[mydata$Sess==24,"GuessFast.12."])
AvgGuessFastSess24[13]<-mean(mydata[mydata$Sess==24,"GuessFast.13."])
AvgGuessFastSess24[14]<-mean(mydata[mydata$Sess==24,"GuessFast.14."])
AvgGuessFastSess24[15]<-mean(mydata[mydata$Sess==24,"GuessFast.15."])
AvgGuessFastSess24[16]<-mean(mydata[mydata$Sess==24,"GuessFast.16."])
AvgGuessFastSess24[17]<-mean(mydata[mydata$Sess==24,"GuessFast.17."])
AvgGuessFastSess24[18]<-mean(mydata[mydata$Sess==24,"GuessFast.18."])
AvgGuessFastSess24[19]<-mean(mydata[mydata$Sess==24,"GuessFast.19."])
AvgGuessFastSess24[20]<-mean(mydata[mydata$Sess==24,"GuessFast.20."])
AvgGuessFastSess24[21]<-mean(mydata[mydata$Sess==24,"GuessFast.21."])
AvgGuessFastSess24[22]<-mean(mydata[mydata$Sess==24,"GuessFast.22."])
AvgGuessFastSess24[23]<-mean(mydata[mydata$Sess==24,"GuessFast.23."])
AvgGuessFastSess24[24]<-mean(mydata[mydata$Sess==24,"GuessFast.24."])
AvgGuessFastSess24[25]<-mean(mydata[mydata$Sess==24,"GuessFast.25."])
AvgGuessSlowSess24<-numeric(25)
AvgGuessSlowSess24[1]<-mean(mydata[mydata$Sess==24,"GuessSlow.1."])
AvgGuessSlowSess24[2]<-mean(mydata[mydata$Sess==24,"GuessSlow.2."])
AvgGuessSlowSess24[3]<-mean(mydata[mydata$Sess==24,"GuessSlow.3."])
AvgGuessSlowSess24[4]<-mean(mydata[mydata$Sess==24,"GuessSlow.4."])
AvgGuessSlowSess24[5]<-mean(mydata[mydata$Sess==24,"GuessSlow.5."])
AvgGuessSlowSess24[6]<-mean(mydata[mydata$Sess==24,"GuessSlow.6."])
AvgGuessSlowSess24[7]<-mean(mydata[mydata$Sess==24,"GuessSlow.7."])
AvgGuessSlowSess24[8]<-mean(mydata[mydata$Sess==24,"GuessSlow.8."])
AvgGuessSlowSess24[9]<-mean(mydata[mydata$Sess==24,"GuessSlow.9."])
AvgGuessSlowSess24[10]<-mean(mydata[mydata$Sess==24,"GuessSlow.10."])
AvgGuessSlowSess24[11]<-mean(mydata[mydata$Sess==24,"GuessSlow.11."])
AvgGuessSlowSess24[12]<-mean(mydata[mydata$Sess==24,"GuessSlow.12."])
AvgGuessSlowSess24[13]<-mean(mydata[mydata$Sess==24,"GuessSlow.13."])
AvgGuessSlowSess24[14]<-mean(mydata[mydata$Sess==24,"GuessSlow.14."])
AvgGuessSlowSess24[15]<-mean(mydata[mydata$Sess==24,"GuessSlow.15."])
AvgGuessSlowSess24[16]<-mean(mydata[mydata$Sess==24,"GuessSlow.16."])
AvgGuessSlowSess24[17]<-mean(mydata[mydata$Sess==24,"GuessSlow.17."])
AvgGuessSlowSess24[18]<-mean(mydata[mydata$Sess==24,"GuessSlow.18."])
AvgGuessSlowSess24[19]<-mean(mydata[mydata$Sess==24,"GuessSlow.19."])
AvgGuessSlowSess24[20]<-mean(mydata[mydata$Sess==24,"GuessSlow.20."])
AvgGuessSlowSess24[21]<-mean(mydata[mydata$Sess==24,"GuessSlow.21."])
AvgGuessSlowSess24[22]<-mean(mydata[mydata$Sess==24,"GuessSlow.22."])
AvgGuessSlowSess24[23]<-mean(mydata[mydata$Sess==24,"GuessSlow.23."])
AvgGuessSlowSess24[24]<-mean(mydata[mydata$Sess==24,"GuessSlow.24."])
AvgGuessSlowSess24[25]<-mean(mydata[mydata$Sess==24,"GuessSlow.25."])
AvgGuessAutoSess24<-numeric(25)
AvgGuessAutoSess24[1]<-mean(mydata[mydata$Sess==24,"GuessAuto.1."])
AvgGuessAutoSess24[2]<-mean(mydata[mydata$Sess==24,"GuessAuto.2."])
AvgGuessAutoSess24[3]<-mean(mydata[mydata$Sess==24,"GuessAuto.3."])
AvgGuessAutoSess24[4]<-mean(mydata[mydata$Sess==24,"GuessAuto.4."])
AvgGuessAutoSess24[5]<-mean(mydata[mydata$Sess==24,"GuessAuto.5."])
AvgGuessAutoSess24[6]<-mean(mydata[mydata$Sess==24,"GuessAuto.6."])
AvgGuessAutoSess24[7]<-mean(mydata[mydata$Sess==24,"GuessAuto.7."])
AvgGuessAutoSess24[8]<-mean(mydata[mydata$Sess==24,"GuessAuto.8."])
AvgGuessAutoSess24[9]<-mean(mydata[mydata$Sess==24,"GuessAuto.9."])
AvgGuessAutoSess24[10]<-mean(mydata[mydata$Sess==24,"GuessAuto.10."])
AvgGuessAutoSess24[11]<-mean(mydata[mydata$Sess==24,"GuessAuto.11."])
AvgGuessAutoSess24[12]<-mean(mydata[mydata$Sess==24,"GuessAuto.12."])
AvgGuessAutoSess24[13]<-mean(mydata[mydata$Sess==24,"GuessAuto.13."])
AvgGuessAutoSess24[14]<-mean(mydata[mydata$Sess==24,"GuessAuto.14."])
AvgGuessAutoSess24[15]<-mean(mydata[mydata$Sess==24,"GuessAuto.15."])
AvgGuessAutoSess24[16]<-mean(mydata[mydata$Sess==24,"GuessAuto.16."])
AvgGuessAutoSess24[17]<-mean(mydata[mydata$Sess==24,"GuessAuto.17."])
AvgGuessAutoSess24[18]<-mean(mydata[mydata$Sess==24,"GuessAuto.18."])
AvgGuessAutoSess24[19]<-mean(mydata[mydata$Sess==24,"GuessAuto.19."])
AvgGuessAutoSess24[20]<-mean(mydata[mydata$Sess==24,"GuessAuto.20."])
AvgGuessAutoSess24[21]<-mean(mydata[mydata$Sess==24,"GuessAuto.21."])
AvgGuessAutoSess24[22]<-mean(mydata[mydata$Sess==24,"GuessAuto.22."])
AvgGuessAutoSess24[23]<-mean(mydata[mydata$Sess==24,"GuessAuto.23."])
AvgGuessAutoSess24[24]<-mean(mydata[mydata$Sess==24,"GuessAuto.24."])
AvgGuessAutoSess24[25]<-mean(mydata[mydata$Sess==24,"GuessAuto.25."])

data <- data.frame(AvgGuessFastSess24, AvgGuessSlowSess24, AvgGuessAutoSess24)
Sess24Plot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess24, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess24, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess24, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 24 (Punishment 2.5)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess24Plot












#Comparing across treatments

data <- data.frame(AvgGuessFastSess1,AvgGuessFastSess2,AvgGuessFastSess3,AvgGuessFastSess4,AvgGuessFastSess5)
FastPlot <- plot_ly(data, x = ~x, y = ~AvgGuessFastSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFastSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFastSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFastSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFastSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Fast",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
FastPlot


data <- data.frame(AvgGuessSlowSess1,AvgGuessSlowSess2,AvgGuessSlowSess3,AvgGuessSlowSess4,AvgGuessSlowSess5)
SlowPlot <- plot_ly(data, x = ~x, y = ~AvgGuessSlowSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessSlowSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessSlowSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessSlowSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Slow",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
SlowPlot


data <- data.frame(AvgGuessAutoSess1,AvgGuessAutoSess2,AvgGuessAutoSess3,AvgGuessAutoSess4,AvgGuessAutoSess5)
AutoPlot <- plot_ly(data, x = ~x, y = ~AvgGuessAutoSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessAutoSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessAutoSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessAutoSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Auto",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AutoPlot

#END OF GUESS

#Start of actual plots

#Plot for Session 1
AvgActualFastSess1<-numeric(25)
AvgActualFastSess1[1]<-mean(mydata[mydata$Sess==1,"ActualFast.1."])
AvgActualFastSess1[2]<-mean(mydata[mydata$Sess==1,"ActualFast.2."])
AvgActualFastSess1[3]<-mean(mydata[mydata$Sess==1,"ActualFast.3."])
AvgActualFastSess1[4]<-mean(mydata[mydata$Sess==1,"ActualFast.4."])
AvgActualFastSess1[5]<-mean(mydata[mydata$Sess==1,"ActualFast.5."])
AvgActualFastSess1[6]<-mean(mydata[mydata$Sess==1,"ActualFast.6."])
AvgActualFastSess1[7]<-mean(mydata[mydata$Sess==1,"ActualFast.7."])
AvgActualFastSess1[8]<-mean(mydata[mydata$Sess==1,"ActualFast.8."])
AvgActualFastSess1[9]<-mean(mydata[mydata$Sess==1,"ActualFast.9."])
AvgActualFastSess1[10]<-mean(mydata[mydata$Sess==1,"ActualFast.10."])
AvgActualFastSess1[11]<-mean(mydata[mydata$Sess==1,"ActualFast.11."])
AvgActualFastSess1[12]<-mean(mydata[mydata$Sess==1,"ActualFast.12."])
AvgActualFastSess1[13]<-mean(mydata[mydata$Sess==1,"ActualFast.13."])
AvgActualFastSess1[14]<-mean(mydata[mydata$Sess==1,"ActualFast.14."])
AvgActualFastSess1[15]<-mean(mydata[mydata$Sess==1,"ActualFast.15."])
AvgActualFastSess1[16]<-mean(mydata[mydata$Sess==1,"ActualFast.16."])
AvgActualFastSess1[17]<-mean(mydata[mydata$Sess==1,"ActualFast.17."])
AvgActualFastSess1[18]<-mean(mydata[mydata$Sess==1,"ActualFast.18."])
AvgActualFastSess1[19]<-mean(mydata[mydata$Sess==1,"ActualFast.19."])
AvgActualFastSess1[20]<-mean(mydata[mydata$Sess==1,"ActualFast.20."])
AvgActualFastSess1[21]<-mean(mydata[mydata$Sess==1,"ActualFast.21."])
AvgActualFastSess1[22]<-mean(mydata[mydata$Sess==1,"ActualFast.22."])
AvgActualFastSess1[23]<-mean(mydata[mydata$Sess==1,"ActualFast.23."])
AvgActualFastSess1[24]<-mean(mydata[mydata$Sess==1,"ActualFast.24."])
AvgActualFastSess1[25]<-mean(mydata[mydata$Sess==1,"ActualFast.25."])
AvgActualSlowSess1<-numeric(25)
AvgActualSlowSess1[1]<-mean(mydata[mydata$Sess==1,"ActualSlow.1."])
AvgActualSlowSess1[2]<-mean(mydata[mydata$Sess==1,"ActualSlow.2."])
AvgActualSlowSess1[3]<-mean(mydata[mydata$Sess==1,"ActualSlow.3."])
AvgActualSlowSess1[4]<-mean(mydata[mydata$Sess==1,"ActualSlow.4."])
AvgActualSlowSess1[5]<-mean(mydata[mydata$Sess==1,"ActualSlow.5."])
AvgActualSlowSess1[6]<-mean(mydata[mydata$Sess==1,"ActualSlow.6."])
AvgActualSlowSess1[7]<-mean(mydata[mydata$Sess==1,"ActualSlow.7."])
AvgActualSlowSess1[8]<-mean(mydata[mydata$Sess==1,"ActualSlow.8."])
AvgActualSlowSess1[9]<-mean(mydata[mydata$Sess==1,"ActualSlow.9."])
AvgActualSlowSess1[10]<-mean(mydata[mydata$Sess==1,"ActualSlow.10."])
AvgActualSlowSess1[11]<-mean(mydata[mydata$Sess==1,"ActualSlow.11."])
AvgActualSlowSess1[12]<-mean(mydata[mydata$Sess==1,"ActualSlow.12."])
AvgActualSlowSess1[13]<-mean(mydata[mydata$Sess==1,"ActualSlow.13."])
AvgActualSlowSess1[14]<-mean(mydata[mydata$Sess==1,"ActualSlow.14."])
AvgActualSlowSess1[15]<-mean(mydata[mydata$Sess==1,"ActualSlow.15."])
AvgActualSlowSess1[16]<-mean(mydata[mydata$Sess==1,"ActualSlow.16."])
AvgActualSlowSess1[17]<-mean(mydata[mydata$Sess==1,"ActualSlow.17."])
AvgActualSlowSess1[18]<-mean(mydata[mydata$Sess==1,"ActualSlow.18."])
AvgActualSlowSess1[19]<-mean(mydata[mydata$Sess==1,"ActualSlow.19."])
AvgActualSlowSess1[20]<-mean(mydata[mydata$Sess==1,"ActualSlow.20."])
AvgActualSlowSess1[21]<-mean(mydata[mydata$Sess==1,"ActualSlow.21."])
AvgActualSlowSess1[22]<-mean(mydata[mydata$Sess==1,"ActualSlow.22."])
AvgActualSlowSess1[23]<-mean(mydata[mydata$Sess==1,"ActualSlow.23."])
AvgActualSlowSess1[24]<-mean(mydata[mydata$Sess==1,"ActualSlow.24."])
AvgActualSlowSess1[25]<-mean(mydata[mydata$Sess==1,"ActualSlow.25."])
AvgActualAutoSess1<-numeric(25)
AvgActualAutoSess1[1]<-mean(mydata[mydata$Sess==1,"ActualAuto.1."])
AvgActualAutoSess1[2]<-mean(mydata[mydata$Sess==1,"ActualAuto.2."])
AvgActualAutoSess1[3]<-mean(mydata[mydata$Sess==1,"ActualAuto.3."])
AvgActualAutoSess1[4]<-mean(mydata[mydata$Sess==1,"ActualAuto.4."])
AvgActualAutoSess1[5]<-mean(mydata[mydata$Sess==1,"ActualAuto.5."])
AvgActualAutoSess1[6]<-mean(mydata[mydata$Sess==1,"ActualAuto.6."])
AvgActualAutoSess1[7]<-mean(mydata[mydata$Sess==1,"ActualAuto.7."])
AvgActualAutoSess1[8]<-mean(mydata[mydata$Sess==1,"ActualAuto.8."])
AvgActualAutoSess1[9]<-mean(mydata[mydata$Sess==1,"ActualAuto.9."])
AvgActualAutoSess1[10]<-mean(mydata[mydata$Sess==1,"ActualAuto.10."])
AvgActualAutoSess1[11]<-mean(mydata[mydata$Sess==1,"ActualAuto.11."])
AvgActualAutoSess1[12]<-mean(mydata[mydata$Sess==1,"ActualAuto.12."])
AvgActualAutoSess1[13]<-mean(mydata[mydata$Sess==1,"ActualAuto.13."])
AvgActualAutoSess1[14]<-mean(mydata[mydata$Sess==1,"ActualAuto.14."])
AvgActualAutoSess1[15]<-mean(mydata[mydata$Sess==1,"ActualAuto.15."])
AvgActualAutoSess1[16]<-mean(mydata[mydata$Sess==1,"ActualAuto.16."])
AvgActualAutoSess1[17]<-mean(mydata[mydata$Sess==1,"ActualAuto.17."])
AvgActualAutoSess1[18]<-mean(mydata[mydata$Sess==1,"ActualAuto.18."])
AvgActualAutoSess1[19]<-mean(mydata[mydata$Sess==1,"ActualAuto.19."])
AvgActualAutoSess1[20]<-mean(mydata[mydata$Sess==1,"ActualAuto.20."])
AvgActualAutoSess1[21]<-mean(mydata[mydata$Sess==1,"ActualAuto.21."])
AvgActualAutoSess1[22]<-mean(mydata[mydata$Sess==1,"ActualAuto.22."])
AvgActualAutoSess1[23]<-mean(mydata[mydata$Sess==1,"ActualAuto.23."])
AvgActualAutoSess1[24]<-mean(mydata[mydata$Sess==1,"ActualAuto.24."])
AvgActualAutoSess1[25]<-mean(mydata[mydata$Sess==1,"ActualAuto.25."])


x<-c(1:25)
data <- data.frame(AvgActualFastSess1, AvgActualSlowSess1, AvgActualAutoSess1)
Sess1PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess1, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess1, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess1, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 1 (Control 1)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess1PlotActual


Auto <- jitter(AvgActualAutoSess1)
Slow <- jitter(AvgActualSlowSess1)
Fast <- jitter(AvgActualFastSess1)
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess1TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess1TriActual


#Auto <- AvgActualAutoSess1
#Slow <- AvgActualSlowSess1
#Fast <- AvgActualFastSess1
Auto <- jitter(AvgActualAutoSess1)
Slow <- jitter(AvgActualSlowSess1)
Fast <- jitter(AvgActualFastSess1)

Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess1Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 1 - Control 1') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))+coord_tern(expand = TRUE)

Sess1Tri2Actual


#Plot for Session 2 Actual data
AvgActualFastSess2<-numeric(25)
AvgActualFastSess2[1]<-mean(mydata[mydata$Sess==2,"ActualFast.1."])
AvgActualFastSess2[2]<-mean(mydata[mydata$Sess==2,"ActualFast.2."])
AvgActualFastSess2[3]<-mean(mydata[mydata$Sess==2,"ActualFast.3."])
AvgActualFastSess2[4]<-mean(mydata[mydata$Sess==2,"ActualFast.4."])
AvgActualFastSess2[5]<-mean(mydata[mydata$Sess==2,"ActualFast.5."])
AvgActualFastSess2[6]<-mean(mydata[mydata$Sess==2,"ActualFast.6."])
AvgActualFastSess2[7]<-mean(mydata[mydata$Sess==2,"ActualFast.7."])
AvgActualFastSess2[8]<-mean(mydata[mydata$Sess==2,"ActualFast.8."])
AvgActualFastSess2[9]<-mean(mydata[mydata$Sess==2,"ActualFast.9."])
AvgActualFastSess2[10]<-mean(mydata[mydata$Sess==2,"ActualFast.10."])
AvgActualFastSess2[11]<-mean(mydata[mydata$Sess==2,"ActualFast.11."])
AvgActualFastSess2[12]<-mean(mydata[mydata$Sess==2,"ActualFast.12."])
AvgActualFastSess2[13]<-mean(mydata[mydata$Sess==2,"ActualFast.13."])
AvgActualFastSess2[14]<-mean(mydata[mydata$Sess==2,"ActualFast.14."])
AvgActualFastSess2[15]<-mean(mydata[mydata$Sess==2,"ActualFast.15."])
AvgActualFastSess2[16]<-mean(mydata[mydata$Sess==2,"ActualFast.16."])
AvgActualFastSess2[17]<-mean(mydata[mydata$Sess==2,"ActualFast.17."])
AvgActualFastSess2[18]<-mean(mydata[mydata$Sess==2,"ActualFast.18."])
AvgActualFastSess2[19]<-mean(mydata[mydata$Sess==2,"ActualFast.19."])
AvgActualFastSess2[20]<-mean(mydata[mydata$Sess==2,"ActualFast.20."])
AvgActualFastSess2[21]<-mean(mydata[mydata$Sess==2,"ActualFast.21."])
AvgActualFastSess2[22]<-mean(mydata[mydata$Sess==2,"ActualFast.22."])
AvgActualFastSess2[23]<-mean(mydata[mydata$Sess==2,"ActualFast.23."])
AvgActualFastSess2[24]<-mean(mydata[mydata$Sess==2,"ActualFast.24."])
AvgActualFastSess2[25]<-mean(mydata[mydata$Sess==2,"ActualFast.25."])
AvgActualSlowSess2<-numeric(25)
AvgActualSlowSess2[1]<-mean(mydata[mydata$Sess==2,"ActualSlow.1."])
AvgActualSlowSess2[2]<-mean(mydata[mydata$Sess==2,"ActualSlow.2."])
AvgActualSlowSess2[3]<-mean(mydata[mydata$Sess==2,"ActualSlow.3."])
AvgActualSlowSess2[4]<-mean(mydata[mydata$Sess==2,"ActualSlow.4."])
AvgActualSlowSess2[5]<-mean(mydata[mydata$Sess==2,"ActualSlow.5."])
AvgActualSlowSess2[6]<-mean(mydata[mydata$Sess==2,"ActualSlow.6."])
AvgActualSlowSess2[7]<-mean(mydata[mydata$Sess==2,"ActualSlow.7."])
AvgActualSlowSess2[8]<-mean(mydata[mydata$Sess==2,"ActualSlow.8."])
AvgActualSlowSess2[9]<-mean(mydata[mydata$Sess==2,"ActualSlow.9."])
AvgActualSlowSess2[10]<-mean(mydata[mydata$Sess==2,"ActualSlow.10."])
AvgActualSlowSess2[11]<-mean(mydata[mydata$Sess==2,"ActualSlow.11."])
AvgActualSlowSess2[12]<-mean(mydata[mydata$Sess==2,"ActualSlow.12."])
AvgActualSlowSess2[13]<-mean(mydata[mydata$Sess==2,"ActualSlow.13."])
AvgActualSlowSess2[14]<-mean(mydata[mydata$Sess==2,"ActualSlow.14."])
AvgActualSlowSess2[15]<-mean(mydata[mydata$Sess==2,"ActualSlow.15."])
AvgActualSlowSess2[16]<-mean(mydata[mydata$Sess==2,"ActualSlow.16."])
AvgActualSlowSess2[17]<-mean(mydata[mydata$Sess==2,"ActualSlow.17."])
AvgActualSlowSess2[18]<-mean(mydata[mydata$Sess==2,"ActualSlow.18."])
AvgActualSlowSess2[19]<-mean(mydata[mydata$Sess==2,"ActualSlow.19."])
AvgActualSlowSess2[20]<-mean(mydata[mydata$Sess==2,"ActualSlow.20."])
AvgActualSlowSess2[21]<-mean(mydata[mydata$Sess==2,"ActualSlow.21."])
AvgActualSlowSess2[22]<-mean(mydata[mydata$Sess==2,"ActualSlow.22."])
AvgActualSlowSess2[23]<-mean(mydata[mydata$Sess==2,"ActualSlow.23."])
AvgActualSlowSess2[24]<-mean(mydata[mydata$Sess==2,"ActualSlow.24."])
AvgActualSlowSess2[25]<-mean(mydata[mydata$Sess==2,"ActualSlow.25."])
AvgActualAutoSess2<-numeric(25)
AvgActualAutoSess2[1]<-mean(mydata[mydata$Sess==2,"ActualAuto.1."])
AvgActualAutoSess2[2]<-mean(mydata[mydata$Sess==2,"ActualAuto.2."])
AvgActualAutoSess2[3]<-mean(mydata[mydata$Sess==2,"ActualAuto.3."])
AvgActualAutoSess2[4]<-mean(mydata[mydata$Sess==2,"ActualAuto.4."])
AvgActualAutoSess2[5]<-mean(mydata[mydata$Sess==2,"ActualAuto.5."])
AvgActualAutoSess2[6]<-mean(mydata[mydata$Sess==2,"ActualAuto.6."])
AvgActualAutoSess2[7]<-mean(mydata[mydata$Sess==2,"ActualAuto.7."])
AvgActualAutoSess2[8]<-mean(mydata[mydata$Sess==2,"ActualAuto.8."])
AvgActualAutoSess2[9]<-mean(mydata[mydata$Sess==2,"ActualAuto.9."])
AvgActualAutoSess2[10]<-mean(mydata[mydata$Sess==2,"ActualAuto.10."])
AvgActualAutoSess2[11]<-mean(mydata[mydata$Sess==2,"ActualAuto.11."])
AvgActualAutoSess2[12]<-mean(mydata[mydata$Sess==2,"ActualAuto.12."])
AvgActualAutoSess2[13]<-mean(mydata[mydata$Sess==2,"ActualAuto.13."])
AvgActualAutoSess2[14]<-mean(mydata[mydata$Sess==2,"ActualAuto.14."])
AvgActualAutoSess2[15]<-mean(mydata[mydata$Sess==2,"ActualAuto.15."])
AvgActualAutoSess2[16]<-mean(mydata[mydata$Sess==2,"ActualAuto.16."])
AvgActualAutoSess2[17]<-mean(mydata[mydata$Sess==2,"ActualAuto.17."])
AvgActualAutoSess2[18]<-mean(mydata[mydata$Sess==2,"ActualAuto.18."])
AvgActualAutoSess2[19]<-mean(mydata[mydata$Sess==2,"ActualAuto.19."])
AvgActualAutoSess2[20]<-mean(mydata[mydata$Sess==2,"ActualAuto.20."])
AvgActualAutoSess2[21]<-mean(mydata[mydata$Sess==2,"ActualAuto.21."])
AvgActualAutoSess2[22]<-mean(mydata[mydata$Sess==2,"ActualAuto.22."])
AvgActualAutoSess2[23]<-mean(mydata[mydata$Sess==2,"ActualAuto.23."])
AvgActualAutoSess2[24]<-mean(mydata[mydata$Sess==2,"ActualAuto.24."])
AvgActualAutoSess2[25]<-mean(mydata[mydata$Sess==2,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess2, AvgActualSlowSess2, AvgActualAutoSess2)
Sess2PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess2, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess2, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess2, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 2 (Fine 1)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess2PlotActual

Auto <- jitter(AvgActualAutoSess2)
Slow <- jitter(AvgActualSlowSess2)
Fast <- jitter(AvgActualFastSess2)
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess2TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess2TriActual

Auto <- jitter(AvgActualAutoSess2)
Slow <- jitter(AvgActualSlowSess2)
Fast <- jitter(AvgActualFastSess2)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess2Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 2 - Fine 1') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))
Sess2Tri2Actual


#Plot for Session 3
AvgActualFastSess3<-numeric(25)
AvgActualFastSess3[1]<-mean(mydata[mydata$Sess==3,"ActualFast.1."])
AvgActualFastSess3[2]<-mean(mydata[mydata$Sess==3,"ActualFast.2."])
AvgActualFastSess3[3]<-mean(mydata[mydata$Sess==3,"ActualFast.3."])
AvgActualFastSess3[4]<-mean(mydata[mydata$Sess==3,"ActualFast.4."])
AvgActualFastSess3[5]<-mean(mydata[mydata$Sess==3,"ActualFast.5."])
AvgActualFastSess3[6]<-mean(mydata[mydata$Sess==3,"ActualFast.6."])
AvgActualFastSess3[7]<-mean(mydata[mydata$Sess==3,"ActualFast.7."])
AvgActualFastSess3[8]<-mean(mydata[mydata$Sess==3,"ActualFast.8."])
AvgActualFastSess3[9]<-mean(mydata[mydata$Sess==3,"ActualFast.9."])
AvgActualFastSess3[10]<-mean(mydata[mydata$Sess==3,"ActualFast.10."])
AvgActualFastSess3[11]<-mean(mydata[mydata$Sess==3,"ActualFast.11."])
AvgActualFastSess3[12]<-mean(mydata[mydata$Sess==3,"ActualFast.12."])
AvgActualFastSess3[13]<-mean(mydata[mydata$Sess==3,"ActualFast.13."])
AvgActualFastSess3[14]<-mean(mydata[mydata$Sess==3,"ActualFast.14."])
AvgActualFastSess3[15]<-mean(mydata[mydata$Sess==3,"ActualFast.15."])
AvgActualFastSess3[16]<-mean(mydata[mydata$Sess==3,"ActualFast.16."])
AvgActualFastSess3[17]<-mean(mydata[mydata$Sess==3,"ActualFast.17."])
AvgActualFastSess3[18]<-mean(mydata[mydata$Sess==3,"ActualFast.18."])
AvgActualFastSess3[19]<-mean(mydata[mydata$Sess==3,"ActualFast.19."])
AvgActualFastSess3[20]<-mean(mydata[mydata$Sess==3,"ActualFast.20."])
AvgActualFastSess3[21]<-mean(mydata[mydata$Sess==3,"ActualFast.21."])
AvgActualFastSess3[22]<-mean(mydata[mydata$Sess==3,"ActualFast.22."])
AvgActualFastSess3[23]<-mean(mydata[mydata$Sess==3,"ActualFast.23."])
AvgActualFastSess3[24]<-mean(mydata[mydata$Sess==3,"ActualFast.24."])
AvgActualFastSess3[25]<-mean(mydata[mydata$Sess==3,"ActualFast.25."])
AvgActualSlowSess3<-numeric(25)
AvgActualSlowSess3[1]<-mean(mydata[mydata$Sess==3,"ActualSlow.1."])
AvgActualSlowSess3[2]<-mean(mydata[mydata$Sess==3,"ActualSlow.2."])
AvgActualSlowSess3[3]<-mean(mydata[mydata$Sess==3,"ActualSlow.3."])
AvgActualSlowSess3[4]<-mean(mydata[mydata$Sess==3,"ActualSlow.4."])
AvgActualSlowSess3[5]<-mean(mydata[mydata$Sess==3,"ActualSlow.5."])
AvgActualSlowSess3[6]<-mean(mydata[mydata$Sess==3,"ActualSlow.6."])
AvgActualSlowSess3[7]<-mean(mydata[mydata$Sess==3,"ActualSlow.7."])
AvgActualSlowSess3[8]<-mean(mydata[mydata$Sess==3,"ActualSlow.8."])
AvgActualSlowSess3[9]<-mean(mydata[mydata$Sess==3,"ActualSlow.9."])
AvgActualSlowSess3[10]<-mean(mydata[mydata$Sess==3,"ActualSlow.10."])
AvgActualSlowSess3[11]<-mean(mydata[mydata$Sess==3,"ActualSlow.11."])
AvgActualSlowSess3[12]<-mean(mydata[mydata$Sess==3,"ActualSlow.12."])
AvgActualSlowSess3[13]<-mean(mydata[mydata$Sess==3,"ActualSlow.13."])
AvgActualSlowSess3[14]<-mean(mydata[mydata$Sess==3,"ActualSlow.14."])
AvgActualSlowSess3[15]<-mean(mydata[mydata$Sess==3,"ActualSlow.15."])
AvgActualSlowSess3[16]<-mean(mydata[mydata$Sess==3,"ActualSlow.16."])
AvgActualSlowSess3[17]<-mean(mydata[mydata$Sess==3,"ActualSlow.17."])
AvgActualSlowSess3[18]<-mean(mydata[mydata$Sess==3,"ActualSlow.18."])
AvgActualSlowSess3[19]<-mean(mydata[mydata$Sess==3,"ActualSlow.19."])
AvgActualSlowSess3[20]<-mean(mydata[mydata$Sess==3,"ActualSlow.20."])
AvgActualSlowSess3[21]<-mean(mydata[mydata$Sess==3,"ActualSlow.21."])
AvgActualSlowSess3[22]<-mean(mydata[mydata$Sess==3,"ActualSlow.22."])
AvgActualSlowSess3[23]<-mean(mydata[mydata$Sess==3,"ActualSlow.23."])
AvgActualSlowSess3[24]<-mean(mydata[mydata$Sess==3,"ActualSlow.24."])
AvgActualSlowSess3[25]<-mean(mydata[mydata$Sess==3,"ActualSlow.25."])
AvgActualAutoSess3<-numeric(25)
AvgActualAutoSess3[1]<-mean(mydata[mydata$Sess==3,"ActualAuto.1."])
AvgActualAutoSess3[2]<-mean(mydata[mydata$Sess==3,"ActualAuto.2."])
AvgActualAutoSess3[3]<-mean(mydata[mydata$Sess==3,"ActualAuto.3."])
AvgActualAutoSess3[4]<-mean(mydata[mydata$Sess==3,"ActualAuto.4."])
AvgActualAutoSess3[5]<-mean(mydata[mydata$Sess==3,"ActualAuto.5."])
AvgActualAutoSess3[6]<-mean(mydata[mydata$Sess==3,"ActualAuto.6."])
AvgActualAutoSess3[7]<-mean(mydata[mydata$Sess==3,"ActualAuto.7."])
AvgActualAutoSess3[8]<-mean(mydata[mydata$Sess==3,"ActualAuto.8."])
AvgActualAutoSess3[9]<-mean(mydata[mydata$Sess==3,"ActualAuto.9."])
AvgActualAutoSess3[10]<-mean(mydata[mydata$Sess==3,"ActualAuto.10."])
AvgActualAutoSess3[11]<-mean(mydata[mydata$Sess==3,"ActualAuto.11."])
AvgActualAutoSess3[12]<-mean(mydata[mydata$Sess==3,"ActualAuto.12."])
AvgActualAutoSess3[13]<-mean(mydata[mydata$Sess==3,"ActualAuto.13."])
AvgActualAutoSess3[14]<-mean(mydata[mydata$Sess==3,"ActualAuto.14."])
AvgActualAutoSess3[15]<-mean(mydata[mydata$Sess==3,"ActualAuto.15."])
AvgActualAutoSess3[16]<-mean(mydata[mydata$Sess==3,"ActualAuto.16."])
AvgActualAutoSess3[17]<-mean(mydata[mydata$Sess==3,"ActualAuto.17."])
AvgActualAutoSess3[18]<-mean(mydata[mydata$Sess==3,"ActualAuto.18."])
AvgActualAutoSess3[19]<-mean(mydata[mydata$Sess==3,"ActualAuto.19."])
AvgActualAutoSess3[20]<-mean(mydata[mydata$Sess==3,"ActualAuto.20."])
AvgActualAutoSess3[21]<-mean(mydata[mydata$Sess==3,"ActualAuto.21."])
AvgActualAutoSess3[22]<-mean(mydata[mydata$Sess==3,"ActualAuto.22."])
AvgActualAutoSess3[23]<-mean(mydata[mydata$Sess==3,"ActualAuto.23."])
AvgActualAutoSess3[24]<-mean(mydata[mydata$Sess==3,"ActualAuto.24."])
AvgActualAutoSess3[25]<-mean(mydata[mydata$Sess==3,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess3, AvgActualSlowSess3, AvgActualAutoSess3)
Sess3PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess3, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess3, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess3, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 3 (Association 1)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess3PlotActual

Auto <- jitter(AvgActualAutoSess3)
Slow <- jitter(AvgActualSlowSess3)
Fast <- jitter(AvgActualFastSess3)
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess3TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess3TriActual

Auto <- jitter(AvgActualAutoSess3)
Slow <- jitter(AvgActualSlowSess3)
Fast <- jitter(AvgActualFastSess3)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess3Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 3 -  Association 1') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))
Sess3Tri2Actual


#Plot for Session 4
AvgActualFastSess4<-numeric(25)
AvgActualFastSess4[1]<-mean(mydata[mydata$Sess==4,"ActualFast.1."])
AvgActualFastSess4[2]<-mean(mydata[mydata$Sess==4,"ActualFast.2."])
AvgActualFastSess4[3]<-mean(mydata[mydata$Sess==4,"ActualFast.3."])
AvgActualFastSess4[4]<-mean(mydata[mydata$Sess==4,"ActualFast.4."])
AvgActualFastSess4[5]<-mean(mydata[mydata$Sess==4,"ActualFast.5."])
AvgActualFastSess4[6]<-mean(mydata[mydata$Sess==4,"ActualFast.6."])
AvgActualFastSess4[7]<-mean(mydata[mydata$Sess==4,"ActualFast.7."])
AvgActualFastSess4[8]<-mean(mydata[mydata$Sess==4,"ActualFast.8."])
AvgActualFastSess4[9]<-mean(mydata[mydata$Sess==4,"ActualFast.9."])
AvgActualFastSess4[10]<-mean(mydata[mydata$Sess==4,"ActualFast.10."])
AvgActualFastSess4[11]<-mean(mydata[mydata$Sess==4,"ActualFast.11."])
AvgActualFastSess4[12]<-mean(mydata[mydata$Sess==4,"ActualFast.12."])
AvgActualFastSess4[13]<-mean(mydata[mydata$Sess==4,"ActualFast.13."])
AvgActualFastSess4[14]<-mean(mydata[mydata$Sess==4,"ActualFast.14."])
AvgActualFastSess4[15]<-mean(mydata[mydata$Sess==4,"ActualFast.15."])
AvgActualFastSess4[16]<-mean(mydata[mydata$Sess==4,"ActualFast.16."])
AvgActualFastSess4[17]<-mean(mydata[mydata$Sess==4,"ActualFast.17."])
AvgActualFastSess4[18]<-mean(mydata[mydata$Sess==4,"ActualFast.18."])
AvgActualFastSess4[19]<-mean(mydata[mydata$Sess==4,"ActualFast.19."])
AvgActualFastSess4[20]<-mean(mydata[mydata$Sess==4,"ActualFast.20."])
AvgActualFastSess4[21]<-mean(mydata[mydata$Sess==4,"ActualFast.21."])
AvgActualFastSess4[22]<-mean(mydata[mydata$Sess==4,"ActualFast.22."])
AvgActualFastSess4[23]<-mean(mydata[mydata$Sess==4,"ActualFast.23."])
AvgActualFastSess4[24]<-mean(mydata[mydata$Sess==4,"ActualFast.24."])
AvgActualFastSess4[25]<-mean(mydata[mydata$Sess==4,"ActualFast.25."])
AvgActualSlowSess4<-numeric(25)
AvgActualSlowSess4[1]<-mean(mydata[mydata$Sess==4,"ActualSlow.1."])
AvgActualSlowSess4[2]<-mean(mydata[mydata$Sess==4,"ActualSlow.2."])
AvgActualSlowSess4[3]<-mean(mydata[mydata$Sess==4,"ActualSlow.3."])
AvgActualSlowSess4[4]<-mean(mydata[mydata$Sess==4,"ActualSlow.4."])
AvgActualSlowSess4[5]<-mean(mydata[mydata$Sess==4,"ActualSlow.5."])
AvgActualSlowSess4[6]<-mean(mydata[mydata$Sess==4,"ActualSlow.6."])
AvgActualSlowSess4[7]<-mean(mydata[mydata$Sess==4,"ActualSlow.7."])
AvgActualSlowSess4[8]<-mean(mydata[mydata$Sess==4,"ActualSlow.8."])
AvgActualSlowSess4[9]<-mean(mydata[mydata$Sess==4,"ActualSlow.9."])
AvgActualSlowSess4[10]<-mean(mydata[mydata$Sess==4,"ActualSlow.10."])
AvgActualSlowSess4[11]<-mean(mydata[mydata$Sess==4,"ActualSlow.11."])
AvgActualSlowSess4[12]<-mean(mydata[mydata$Sess==4,"ActualSlow.12."])
AvgActualSlowSess4[13]<-mean(mydata[mydata$Sess==4,"ActualSlow.13."])
AvgActualSlowSess4[14]<-mean(mydata[mydata$Sess==4,"ActualSlow.14."])
AvgActualSlowSess4[15]<-mean(mydata[mydata$Sess==4,"ActualSlow.15."])
AvgActualSlowSess4[16]<-mean(mydata[mydata$Sess==4,"ActualSlow.16."])
AvgActualSlowSess4[17]<-mean(mydata[mydata$Sess==4,"ActualSlow.17."])
AvgActualSlowSess4[18]<-mean(mydata[mydata$Sess==4,"ActualSlow.18."])
AvgActualSlowSess4[19]<-mean(mydata[mydata$Sess==4,"ActualSlow.19."])
AvgActualSlowSess4[20]<-mean(mydata[mydata$Sess==4,"ActualSlow.20."])
AvgActualSlowSess4[21]<-mean(mydata[mydata$Sess==4,"ActualSlow.21."])
AvgActualSlowSess4[22]<-mean(mydata[mydata$Sess==4,"ActualSlow.22."])
AvgActualSlowSess4[23]<-mean(mydata[mydata$Sess==4,"ActualSlow.23."])
AvgActualSlowSess4[24]<-mean(mydata[mydata$Sess==4,"ActualSlow.24."])
AvgActualSlowSess4[25]<-mean(mydata[mydata$Sess==4,"ActualSlow.25."])
AvgActualAutoSess4<-numeric(25)
AvgActualAutoSess4[1]<-mean(mydata[mydata$Sess==4,"ActualAuto.1."])
AvgActualAutoSess4[2]<-mean(mydata[mydata$Sess==4,"ActualAuto.2."])
AvgActualAutoSess4[3]<-mean(mydata[mydata$Sess==4,"ActualAuto.3."])
AvgActualAutoSess4[4]<-mean(mydata[mydata$Sess==4,"ActualAuto.4."])
AvgActualAutoSess4[5]<-mean(mydata[mydata$Sess==4,"ActualAuto.5."])
AvgActualAutoSess4[6]<-mean(mydata[mydata$Sess==4,"ActualAuto.6."])
AvgActualAutoSess4[7]<-mean(mydata[mydata$Sess==4,"ActualAuto.7."])
AvgActualAutoSess4[8]<-mean(mydata[mydata$Sess==4,"ActualAuto.8."])
AvgActualAutoSess4[9]<-mean(mydata[mydata$Sess==4,"ActualAuto.9."])
AvgActualAutoSess4[10]<-mean(mydata[mydata$Sess==4,"ActualAuto.10."])
AvgActualAutoSess4[11]<-mean(mydata[mydata$Sess==4,"ActualAuto.11."])
AvgActualAutoSess4[12]<-mean(mydata[mydata$Sess==4,"ActualAuto.12."])
AvgActualAutoSess4[13]<-mean(mydata[mydata$Sess==4,"ActualAuto.13."])
AvgActualAutoSess4[14]<-mean(mydata[mydata$Sess==4,"ActualAuto.14."])
AvgActualAutoSess4[15]<-mean(mydata[mydata$Sess==4,"ActualAuto.15."])
AvgActualAutoSess4[16]<-mean(mydata[mydata$Sess==4,"ActualAuto.16."])
AvgActualAutoSess4[17]<-mean(mydata[mydata$Sess==4,"ActualAuto.17."])
AvgActualAutoSess4[18]<-mean(mydata[mydata$Sess==4,"ActualAuto.18."])
AvgActualAutoSess4[19]<-mean(mydata[mydata$Sess==4,"ActualAuto.19."])
AvgActualAutoSess4[20]<-mean(mydata[mydata$Sess==4,"ActualAuto.20."])
AvgActualAutoSess4[21]<-mean(mydata[mydata$Sess==4,"ActualAuto.21."])
AvgActualAutoSess4[22]<-mean(mydata[mydata$Sess==4,"ActualAuto.22."])
AvgActualAutoSess4[23]<-mean(mydata[mydata$Sess==4,"ActualAuto.23."])
AvgActualAutoSess4[24]<-mean(mydata[mydata$Sess==4,"ActualAuto.24."])
AvgActualAutoSess4[25]<-mean(mydata[mydata$Sess==4,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess4, AvgActualSlowSess4, AvgActualAutoSess4)
Sess4PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess4, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess4, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess4, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 4 (Association 2)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess4PlotActual


Auto <- jitter(AvgActualAutoSess4)
Slow <- jitter(AvgActualSlowSess4)
Fast <- jitter(AvgActualFastSess4)
label <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,label,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess4TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~label,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess4TriActual

Auto <- jitter(AvgActualAutoSess4)
Slow <- jitter(AvgActualSlowSess4)
Fast <- jitter(AvgActualFastSess4)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess4Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 4 -  Association 2') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))
Sess4Tri2Actual

#Plot for Session 5
AvgActualFastSess5<-numeric(25)
AvgActualFastSess5[1]<-mean(mydata[mydata$Sess==5,"ActualFast.1."])
AvgActualFastSess5[2]<-mean(mydata[mydata$Sess==5,"ActualFast.2."])
AvgActualFastSess5[3]<-mean(mydata[mydata$Sess==5,"ActualFast.3."])
AvgActualFastSess5[4]<-mean(mydata[mydata$Sess==5,"ActualFast.4."])
AvgActualFastSess5[5]<-mean(mydata[mydata$Sess==5,"ActualFast.5."])
AvgActualFastSess5[6]<-mean(mydata[mydata$Sess==5,"ActualFast.6."])
AvgActualFastSess5[7]<-mean(mydata[mydata$Sess==5,"ActualFast.7."])
AvgActualFastSess5[8]<-mean(mydata[mydata$Sess==5,"ActualFast.8."])
AvgActualFastSess5[9]<-mean(mydata[mydata$Sess==5,"ActualFast.9."])
AvgActualFastSess5[10]<-mean(mydata[mydata$Sess==5,"ActualFast.10."])
AvgActualFastSess5[11]<-mean(mydata[mydata$Sess==5,"ActualFast.11."])
AvgActualFastSess5[12]<-mean(mydata[mydata$Sess==5,"ActualFast.12."])
AvgActualFastSess5[13]<-mean(mydata[mydata$Sess==5,"ActualFast.13."])
AvgActualFastSess5[14]<-mean(mydata[mydata$Sess==5,"ActualFast.14."])
AvgActualFastSess5[15]<-mean(mydata[mydata$Sess==5,"ActualFast.15."])
AvgActualFastSess5[16]<-mean(mydata[mydata$Sess==5,"ActualFast.16."])
AvgActualFastSess5[17]<-mean(mydata[mydata$Sess==5,"ActualFast.17."])
AvgActualFastSess5[18]<-mean(mydata[mydata$Sess==5,"ActualFast.18."])
AvgActualFastSess5[19]<-mean(mydata[mydata$Sess==5,"ActualFast.19."])
AvgActualFastSess5[20]<-mean(mydata[mydata$Sess==5,"ActualFast.20."])
AvgActualFastSess5[21]<-mean(mydata[mydata$Sess==5,"ActualFast.21."])
AvgActualFastSess5[22]<-mean(mydata[mydata$Sess==5,"ActualFast.22."])
AvgActualFastSess5[23]<-mean(mydata[mydata$Sess==5,"ActualFast.23."])
AvgActualFastSess5[24]<-mean(mydata[mydata$Sess==5,"ActualFast.24."])
AvgActualFastSess5[25]<-mean(mydata[mydata$Sess==5,"ActualFast.25."])
AvgActualSlowSess5<-numeric(25)
AvgActualSlowSess5[1]<-mean(mydata[mydata$Sess==5,"ActualSlow.1."])
AvgActualSlowSess5[2]<-mean(mydata[mydata$Sess==5,"ActualSlow.2."])
AvgActualSlowSess5[3]<-mean(mydata[mydata$Sess==5,"ActualSlow.3."])
AvgActualSlowSess5[4]<-mean(mydata[mydata$Sess==5,"ActualSlow.4."])
AvgActualSlowSess5[5]<-mean(mydata[mydata$Sess==5,"ActualSlow.5."])
AvgActualSlowSess5[6]<-mean(mydata[mydata$Sess==5,"ActualSlow.6."])
AvgActualSlowSess5[7]<-mean(mydata[mydata$Sess==5,"ActualSlow.7."])
AvgActualSlowSess5[8]<-mean(mydata[mydata$Sess==5,"ActualSlow.8."])
AvgActualSlowSess5[9]<-mean(mydata[mydata$Sess==5,"ActualSlow.9."])
AvgActualSlowSess5[10]<-mean(mydata[mydata$Sess==5,"ActualSlow.10."])
AvgActualSlowSess5[11]<-mean(mydata[mydata$Sess==5,"ActualSlow.11."])
AvgActualSlowSess5[12]<-mean(mydata[mydata$Sess==5,"ActualSlow.12."])
AvgActualSlowSess5[13]<-mean(mydata[mydata$Sess==5,"ActualSlow.13."])
AvgActualSlowSess5[14]<-mean(mydata[mydata$Sess==5,"ActualSlow.14."])
AvgActualSlowSess5[15]<-mean(mydata[mydata$Sess==5,"ActualSlow.15."])
AvgActualSlowSess5[16]<-mean(mydata[mydata$Sess==5,"ActualSlow.16."])
AvgActualSlowSess5[17]<-mean(mydata[mydata$Sess==5,"ActualSlow.17."])
AvgActualSlowSess5[18]<-mean(mydata[mydata$Sess==5,"ActualSlow.18."])
AvgActualSlowSess5[19]<-mean(mydata[mydata$Sess==5,"ActualSlow.19."])
AvgActualSlowSess5[20]<-mean(mydata[mydata$Sess==5,"ActualSlow.20."])
AvgActualSlowSess5[21]<-mean(mydata[mydata$Sess==5,"ActualSlow.21."])
AvgActualSlowSess5[22]<-mean(mydata[mydata$Sess==5,"ActualSlow.22."])
AvgActualSlowSess5[23]<-mean(mydata[mydata$Sess==5,"ActualSlow.23."])
AvgActualSlowSess5[24]<-mean(mydata[mydata$Sess==5,"ActualSlow.24."])
AvgActualSlowSess5[25]<-mean(mydata[mydata$Sess==5,"ActualSlow.25."])
AvgActualAutoSess5<-numeric(25)
AvgActualAutoSess5[1]<-mean(mydata[mydata$Sess==5,"ActualAuto.1."])
AvgActualAutoSess5[2]<-mean(mydata[mydata$Sess==5,"ActualAuto.2."])
AvgActualAutoSess5[3]<-mean(mydata[mydata$Sess==5,"ActualAuto.3."])
AvgActualAutoSess5[4]<-mean(mydata[mydata$Sess==5,"ActualAuto.4."])
AvgActualAutoSess5[5]<-mean(mydata[mydata$Sess==5,"ActualAuto.5."])
AvgActualAutoSess5[6]<-mean(mydata[mydata$Sess==5,"ActualAuto.6."])
AvgActualAutoSess5[7]<-mean(mydata[mydata$Sess==5,"ActualAuto.7."])
AvgActualAutoSess5[8]<-mean(mydata[mydata$Sess==5,"ActualAuto.8."])
AvgActualAutoSess5[9]<-mean(mydata[mydata$Sess==5,"ActualAuto.9."])
AvgActualAutoSess5[10]<-mean(mydata[mydata$Sess==5,"ActualAuto.10."])
AvgActualAutoSess5[11]<-mean(mydata[mydata$Sess==5,"ActualAuto.11."])
AvgActualAutoSess5[12]<-mean(mydata[mydata$Sess==5,"ActualAuto.12."])
AvgActualAutoSess5[13]<-mean(mydata[mydata$Sess==5,"ActualAuto.13."])
AvgActualAutoSess5[14]<-mean(mydata[mydata$Sess==5,"ActualAuto.14."])
AvgActualAutoSess5[15]<-mean(mydata[mydata$Sess==5,"ActualAuto.15."])
AvgActualAutoSess5[16]<-mean(mydata[mydata$Sess==5,"ActualAuto.16."])
AvgActualAutoSess5[17]<-mean(mydata[mydata$Sess==5,"ActualAuto.17."])
AvgActualAutoSess5[18]<-mean(mydata[mydata$Sess==5,"ActualAuto.18."])
AvgActualAutoSess5[19]<-mean(mydata[mydata$Sess==5,"ActualAuto.19."])
AvgActualAutoSess5[20]<-mean(mydata[mydata$Sess==5,"ActualAuto.20."])
AvgActualAutoSess5[21]<-mean(mydata[mydata$Sess==5,"ActualAuto.21."])
AvgActualAutoSess5[22]<-mean(mydata[mydata$Sess==5,"ActualAuto.22."])
AvgActualAutoSess5[23]<-mean(mydata[mydata$Sess==5,"ActualAuto.23."])
AvgActualAutoSess5[24]<-mean(mydata[mydata$Sess==5,"ActualAuto.24."])
AvgActualAutoSess5[25]<-mean(mydata[mydata$Sess==5,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess5, AvgActualSlowSess5, AvgActualAutoSess5)
Sess5PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess5, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess5, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess5, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 5 (Fine 2)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess5PlotActual

Auto <- jitter(AvgActualAutoSess5)
Slow <- jitter(AvgActualSlowSess5)
Fast <- jitter(AvgActualFastSess5)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess5TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess5TriActual


Auto <- jitter(AvgActualAutoSess5)
Slow <- jitter(AvgActualSlowSess5)
Fast <- jitter(AvgActualFastSess5)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess5Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 5 - Fine 2') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess5Tri2Actual



#Plot for Session 6
AvgActualFastSess6<-numeric(25)
AvgActualFastSess6[1]<-mean(mydata[mydata$Sess==6,"ActualFast.1."])
AvgActualFastSess6[2]<-mean(mydata[mydata$Sess==6,"ActualFast.2."])
AvgActualFastSess6[3]<-mean(mydata[mydata$Sess==6,"ActualFast.3."])
AvgActualFastSess6[4]<-mean(mydata[mydata$Sess==6,"ActualFast.4."])
AvgActualFastSess6[5]<-mean(mydata[mydata$Sess==6,"ActualFast.5."])
AvgActualFastSess6[6]<-mean(mydata[mydata$Sess==6,"ActualFast.6."])
AvgActualFastSess6[7]<-mean(mydata[mydata$Sess==6,"ActualFast.7."])
AvgActualFastSess6[8]<-mean(mydata[mydata$Sess==6,"ActualFast.8."])
AvgActualFastSess6[9]<-mean(mydata[mydata$Sess==6,"ActualFast.9."])
AvgActualFastSess6[10]<-mean(mydata[mydata$Sess==6,"ActualFast.10."])
AvgActualFastSess6[11]<-mean(mydata[mydata$Sess==6,"ActualFast.11."])
AvgActualFastSess6[12]<-mean(mydata[mydata$Sess==6,"ActualFast.12."])
AvgActualFastSess6[13]<-mean(mydata[mydata$Sess==6,"ActualFast.13."])
AvgActualFastSess6[14]<-mean(mydata[mydata$Sess==6,"ActualFast.14."])
AvgActualFastSess6[15]<-mean(mydata[mydata$Sess==6,"ActualFast.15."])
AvgActualFastSess6[16]<-mean(mydata[mydata$Sess==6,"ActualFast.16."])
AvgActualFastSess6[17]<-mean(mydata[mydata$Sess==6,"ActualFast.17."])
AvgActualFastSess6[18]<-mean(mydata[mydata$Sess==6,"ActualFast.18."])
AvgActualFastSess6[19]<-mean(mydata[mydata$Sess==6,"ActualFast.19."])
AvgActualFastSess6[20]<-mean(mydata[mydata$Sess==6,"ActualFast.20."])
AvgActualFastSess6[21]<-mean(mydata[mydata$Sess==6,"ActualFast.21."])
AvgActualFastSess6[22]<-mean(mydata[mydata$Sess==6,"ActualFast.22."])
AvgActualFastSess6[23]<-mean(mydata[mydata$Sess==6,"ActualFast.23."])
AvgActualFastSess6[24]<-mean(mydata[mydata$Sess==6,"ActualFast.24."])
AvgActualFastSess6[25]<-mean(mydata[mydata$Sess==6,"ActualFast.25."])
AvgActualSlowSess6<-numeric(25)
AvgActualSlowSess6[1]<-mean(mydata[mydata$Sess==6,"ActualSlow.1."])
AvgActualSlowSess6[2]<-mean(mydata[mydata$Sess==6,"ActualSlow.2."])
AvgActualSlowSess6[3]<-mean(mydata[mydata$Sess==6,"ActualSlow.3."])
AvgActualSlowSess6[4]<-mean(mydata[mydata$Sess==6,"ActualSlow.4."])
AvgActualSlowSess6[5]<-mean(mydata[mydata$Sess==6,"ActualSlow.5."])
AvgActualSlowSess6[6]<-mean(mydata[mydata$Sess==6,"ActualSlow.6."])
AvgActualSlowSess6[7]<-mean(mydata[mydata$Sess==6,"ActualSlow.7."])
AvgActualSlowSess6[8]<-mean(mydata[mydata$Sess==6,"ActualSlow.8."])
AvgActualSlowSess6[9]<-mean(mydata[mydata$Sess==6,"ActualSlow.9."])
AvgActualSlowSess6[10]<-mean(mydata[mydata$Sess==6,"ActualSlow.10."])
AvgActualSlowSess6[11]<-mean(mydata[mydata$Sess==6,"ActualSlow.11."])
AvgActualSlowSess6[12]<-mean(mydata[mydata$Sess==6,"ActualSlow.12."])
AvgActualSlowSess6[13]<-mean(mydata[mydata$Sess==6,"ActualSlow.13."])
AvgActualSlowSess6[14]<-mean(mydata[mydata$Sess==6,"ActualSlow.14."])
AvgActualSlowSess6[15]<-mean(mydata[mydata$Sess==6,"ActualSlow.15."])
AvgActualSlowSess6[16]<-mean(mydata[mydata$Sess==6,"ActualSlow.16."])
AvgActualSlowSess6[17]<-mean(mydata[mydata$Sess==6,"ActualSlow.17."])
AvgActualSlowSess6[18]<-mean(mydata[mydata$Sess==6,"ActualSlow.18."])
AvgActualSlowSess6[19]<-mean(mydata[mydata$Sess==6,"ActualSlow.19."])
AvgActualSlowSess6[20]<-mean(mydata[mydata$Sess==6,"ActualSlow.20."])
AvgActualSlowSess6[21]<-mean(mydata[mydata$Sess==6,"ActualSlow.21."])
AvgActualSlowSess6[22]<-mean(mydata[mydata$Sess==6,"ActualSlow.22."])
AvgActualSlowSess6[23]<-mean(mydata[mydata$Sess==6,"ActualSlow.23."])
AvgActualSlowSess6[24]<-mean(mydata[mydata$Sess==6,"ActualSlow.24."])
AvgActualSlowSess6[25]<-mean(mydata[mydata$Sess==6,"ActualSlow.25."])
AvgActualAutoSess6<-numeric(25)
AvgActualAutoSess6[1]<-mean(mydata[mydata$Sess==6,"ActualAuto.1."])
AvgActualAutoSess6[2]<-mean(mydata[mydata$Sess==6,"ActualAuto.2."])
AvgActualAutoSess6[3]<-mean(mydata[mydata$Sess==6,"ActualAuto.3."])
AvgActualAutoSess6[4]<-mean(mydata[mydata$Sess==6,"ActualAuto.4."])
AvgActualAutoSess6[5]<-mean(mydata[mydata$Sess==6,"ActualAuto.5."])
AvgActualAutoSess6[6]<-mean(mydata[mydata$Sess==6,"ActualAuto.6."])
AvgActualAutoSess6[7]<-mean(mydata[mydata$Sess==6,"ActualAuto.7."])
AvgActualAutoSess6[8]<-mean(mydata[mydata$Sess==6,"ActualAuto.8."])
AvgActualAutoSess6[9]<-mean(mydata[mydata$Sess==6,"ActualAuto.9."])
AvgActualAutoSess6[10]<-mean(mydata[mydata$Sess==6,"ActualAuto.10."])
AvgActualAutoSess6[11]<-mean(mydata[mydata$Sess==6,"ActualAuto.11."])
AvgActualAutoSess6[12]<-mean(mydata[mydata$Sess==6,"ActualAuto.12."])
AvgActualAutoSess6[13]<-mean(mydata[mydata$Sess==6,"ActualAuto.13."])
AvgActualAutoSess6[14]<-mean(mydata[mydata$Sess==6,"ActualAuto.14."])
AvgActualAutoSess6[15]<-mean(mydata[mydata$Sess==6,"ActualAuto.15."])
AvgActualAutoSess6[16]<-mean(mydata[mydata$Sess==6,"ActualAuto.16."])
AvgActualAutoSess6[17]<-mean(mydata[mydata$Sess==6,"ActualAuto.17."])
AvgActualAutoSess6[18]<-mean(mydata[mydata$Sess==6,"ActualAuto.18."])
AvgActualAutoSess6[19]<-mean(mydata[mydata$Sess==6,"ActualAuto.19."])
AvgActualAutoSess6[20]<-mean(mydata[mydata$Sess==6,"ActualAuto.20."])
AvgActualAutoSess6[21]<-mean(mydata[mydata$Sess==6,"ActualAuto.21."])
AvgActualAutoSess6[22]<-mean(mydata[mydata$Sess==6,"ActualAuto.22."])
AvgActualAutoSess6[23]<-mean(mydata[mydata$Sess==6,"ActualAuto.23."])
AvgActualAutoSess6[24]<-mean(mydata[mydata$Sess==6,"ActualAuto.24."])
AvgActualAutoSess6[25]<-mean(mydata[mydata$Sess==6,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess6, AvgActualSlowSess6, AvgActualAutoSess6)
Sess6PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess6, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess6, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess6, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 6 (Control 2)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess6PlotActual

Auto <- jitter(AvgActualAutoSess6)
Slow <- jitter(AvgActualSlowSess6)
Fast <- jitter(AvgActualFastSess6)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess6TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess6TriActual


Auto <- jitter(AvgActualAutoSess6)
Slow <- jitter(AvgActualSlowSess6)
Fast <- jitter(AvgActualFastSess6)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess6Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 6 - Control 2') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess6Tri2Actual


#Plot for Session 7
AvgActualFastSess7<-numeric(25)
AvgActualFastSess7[1]<-mean(mydata[mydata$Sess==7,"ActualFast.1."])
AvgActualFastSess7[2]<-mean(mydata[mydata$Sess==7,"ActualFast.2."])
AvgActualFastSess7[3]<-mean(mydata[mydata$Sess==7,"ActualFast.3."])
AvgActualFastSess7[4]<-mean(mydata[mydata$Sess==7,"ActualFast.4."])
AvgActualFastSess7[5]<-mean(mydata[mydata$Sess==7,"ActualFast.5."])
AvgActualFastSess7[6]<-mean(mydata[mydata$Sess==7,"ActualFast.6."])
AvgActualFastSess7[7]<-mean(mydata[mydata$Sess==7,"ActualFast.7."])
AvgActualFastSess7[8]<-mean(mydata[mydata$Sess==7,"ActualFast.8."])
AvgActualFastSess7[9]<-mean(mydata[mydata$Sess==7,"ActualFast.9."])
AvgActualFastSess7[10]<-mean(mydata[mydata$Sess==7,"ActualFast.10."])
AvgActualFastSess7[11]<-mean(mydata[mydata$Sess==7,"ActualFast.11."])
AvgActualFastSess7[12]<-mean(mydata[mydata$Sess==7,"ActualFast.12."])
AvgActualFastSess7[13]<-mean(mydata[mydata$Sess==7,"ActualFast.13."])
AvgActualFastSess7[14]<-mean(mydata[mydata$Sess==7,"ActualFast.14."])
AvgActualFastSess7[15]<-mean(mydata[mydata$Sess==7,"ActualFast.15."])
AvgActualFastSess7[16]<-mean(mydata[mydata$Sess==7,"ActualFast.16."])
AvgActualFastSess7[17]<-mean(mydata[mydata$Sess==7,"ActualFast.17."])
AvgActualFastSess7[18]<-mean(mydata[mydata$Sess==7,"ActualFast.18."])
AvgActualFastSess7[19]<-mean(mydata[mydata$Sess==7,"ActualFast.19."])
AvgActualFastSess7[20]<-mean(mydata[mydata$Sess==7,"ActualFast.20."])
AvgActualFastSess7[21]<-mean(mydata[mydata$Sess==7,"ActualFast.21."])
AvgActualFastSess7[22]<-mean(mydata[mydata$Sess==7,"ActualFast.22."])
AvgActualFastSess7[23]<-mean(mydata[mydata$Sess==7,"ActualFast.23."])
AvgActualFastSess7[24]<-mean(mydata[mydata$Sess==7,"ActualFast.24."])
AvgActualFastSess7[25]<-mean(mydata[mydata$Sess==7,"ActualFast.25."])
AvgActualSlowSess7<-numeric(25)
AvgActualSlowSess7[1]<-mean(mydata[mydata$Sess==7,"ActualSlow.1."])
AvgActualSlowSess7[2]<-mean(mydata[mydata$Sess==7,"ActualSlow.2."])
AvgActualSlowSess7[3]<-mean(mydata[mydata$Sess==7,"ActualSlow.3."])
AvgActualSlowSess7[4]<-mean(mydata[mydata$Sess==7,"ActualSlow.4."])
AvgActualSlowSess7[5]<-mean(mydata[mydata$Sess==7,"ActualSlow.5."])
AvgActualSlowSess7[6]<-mean(mydata[mydata$Sess==7,"ActualSlow.6."])
AvgActualSlowSess7[7]<-mean(mydata[mydata$Sess==7,"ActualSlow.7."])
AvgActualSlowSess7[8]<-mean(mydata[mydata$Sess==7,"ActualSlow.8."])
AvgActualSlowSess7[9]<-mean(mydata[mydata$Sess==7,"ActualSlow.9."])
AvgActualSlowSess7[10]<-mean(mydata[mydata$Sess==7,"ActualSlow.10."])
AvgActualSlowSess7[11]<-mean(mydata[mydata$Sess==7,"ActualSlow.11."])
AvgActualSlowSess7[12]<-mean(mydata[mydata$Sess==7,"ActualSlow.12."])
AvgActualSlowSess7[13]<-mean(mydata[mydata$Sess==7,"ActualSlow.13."])
AvgActualSlowSess7[14]<-mean(mydata[mydata$Sess==7,"ActualSlow.14."])
AvgActualSlowSess7[15]<-mean(mydata[mydata$Sess==7,"ActualSlow.15."])
AvgActualSlowSess7[16]<-mean(mydata[mydata$Sess==7,"ActualSlow.16."])
AvgActualSlowSess7[17]<-mean(mydata[mydata$Sess==7,"ActualSlow.17."])
AvgActualSlowSess7[18]<-mean(mydata[mydata$Sess==7,"ActualSlow.18."])
AvgActualSlowSess7[19]<-mean(mydata[mydata$Sess==7,"ActualSlow.19."])
AvgActualSlowSess7[20]<-mean(mydata[mydata$Sess==7,"ActualSlow.20."])
AvgActualSlowSess7[21]<-mean(mydata[mydata$Sess==7,"ActualSlow.21."])
AvgActualSlowSess7[22]<-mean(mydata[mydata$Sess==7,"ActualSlow.22."])
AvgActualSlowSess7[23]<-mean(mydata[mydata$Sess==7,"ActualSlow.23."])
AvgActualSlowSess7[24]<-mean(mydata[mydata$Sess==7,"ActualSlow.24."])
AvgActualSlowSess7[25]<-mean(mydata[mydata$Sess==7,"ActualSlow.25."])
AvgActualAutoSess7<-numeric(25)
AvgActualAutoSess7[1]<-mean(mydata[mydata$Sess==7,"ActualAuto.1."])
AvgActualAutoSess7[2]<-mean(mydata[mydata$Sess==7,"ActualAuto.2."])
AvgActualAutoSess7[3]<-mean(mydata[mydata$Sess==7,"ActualAuto.3."])
AvgActualAutoSess7[4]<-mean(mydata[mydata$Sess==7,"ActualAuto.4."])
AvgActualAutoSess7[5]<-mean(mydata[mydata$Sess==7,"ActualAuto.5."])
AvgActualAutoSess7[6]<-mean(mydata[mydata$Sess==7,"ActualAuto.6."])
AvgActualAutoSess7[7]<-mean(mydata[mydata$Sess==7,"ActualAuto.7."])
AvgActualAutoSess7[8]<-mean(mydata[mydata$Sess==7,"ActualAuto.8."])
AvgActualAutoSess7[9]<-mean(mydata[mydata$Sess==7,"ActualAuto.9."])
AvgActualAutoSess7[10]<-mean(mydata[mydata$Sess==7,"ActualAuto.10."])
AvgActualAutoSess7[11]<-mean(mydata[mydata$Sess==7,"ActualAuto.11."])
AvgActualAutoSess7[12]<-mean(mydata[mydata$Sess==7,"ActualAuto.12."])
AvgActualAutoSess7[13]<-mean(mydata[mydata$Sess==7,"ActualAuto.13."])
AvgActualAutoSess7[14]<-mean(mydata[mydata$Sess==7,"ActualAuto.14."])
AvgActualAutoSess7[15]<-mean(mydata[mydata$Sess==7,"ActualAuto.15."])
AvgActualAutoSess7[16]<-mean(mydata[mydata$Sess==7,"ActualAuto.16."])
AvgActualAutoSess7[17]<-mean(mydata[mydata$Sess==7,"ActualAuto.17."])
AvgActualAutoSess7[18]<-mean(mydata[mydata$Sess==7,"ActualAuto.18."])
AvgActualAutoSess7[19]<-mean(mydata[mydata$Sess==7,"ActualAuto.19."])
AvgActualAutoSess7[20]<-mean(mydata[mydata$Sess==7,"ActualAuto.20."])
AvgActualAutoSess7[21]<-mean(mydata[mydata$Sess==7,"ActualAuto.21."])
AvgActualAutoSess7[22]<-mean(mydata[mydata$Sess==7,"ActualAuto.22."])
AvgActualAutoSess7[23]<-mean(mydata[mydata$Sess==7,"ActualAuto.23."])
AvgActualAutoSess7[24]<-mean(mydata[mydata$Sess==7,"ActualAuto.24."])
AvgActualAutoSess7[25]<-mean(mydata[mydata$Sess==7,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess7, AvgActualSlowSess7, AvgActualAutoSess7)
Sess7PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess7, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess7, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess7, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 7 (Control 3)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess7PlotActual

Auto <- jitter(AvgActualAutoSess7)
Slow <- jitter(AvgActualSlowSess7)
Fast <- jitter(AvgActualFastSess7)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess7TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess7TriActual


Auto <- jitter(AvgActualAutoSess7)
Slow <- jitter(AvgActualSlowSess7)
Fast <- jitter(AvgActualFastSess7)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess7Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 7 - Control 3') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess7Tri2Actual



#Plot for Session 8
AvgActualFastSess8<-numeric(25)
AvgActualFastSess8[1]<-mean(mydata[mydata$Sess==8,"ActualFast.1."])
AvgActualFastSess8[2]<-mean(mydata[mydata$Sess==8,"ActualFast.2."])
AvgActualFastSess8[3]<-mean(mydata[mydata$Sess==8,"ActualFast.3."])
AvgActualFastSess8[4]<-mean(mydata[mydata$Sess==8,"ActualFast.4."])
AvgActualFastSess8[5]<-mean(mydata[mydata$Sess==8,"ActualFast.5."])
AvgActualFastSess8[6]<-mean(mydata[mydata$Sess==8,"ActualFast.6."])
AvgActualFastSess8[7]<-mean(mydata[mydata$Sess==8,"ActualFast.7."])
AvgActualFastSess8[8]<-mean(mydata[mydata$Sess==8,"ActualFast.8."])
AvgActualFastSess8[9]<-mean(mydata[mydata$Sess==8,"ActualFast.9."])
AvgActualFastSess8[10]<-mean(mydata[mydata$Sess==8,"ActualFast.10."])
AvgActualFastSess8[11]<-mean(mydata[mydata$Sess==8,"ActualFast.11."])
AvgActualFastSess8[12]<-mean(mydata[mydata$Sess==8,"ActualFast.12."])
AvgActualFastSess8[13]<-mean(mydata[mydata$Sess==8,"ActualFast.13."])
AvgActualFastSess8[14]<-mean(mydata[mydata$Sess==8,"ActualFast.14."])
AvgActualFastSess8[15]<-mean(mydata[mydata$Sess==8,"ActualFast.15."])
AvgActualFastSess8[16]<-mean(mydata[mydata$Sess==8,"ActualFast.16."])
AvgActualFastSess8[17]<-mean(mydata[mydata$Sess==8,"ActualFast.17."])
AvgActualFastSess8[18]<-mean(mydata[mydata$Sess==8,"ActualFast.18."])
AvgActualFastSess8[19]<-mean(mydata[mydata$Sess==8,"ActualFast.19."])
AvgActualFastSess8[20]<-mean(mydata[mydata$Sess==8,"ActualFast.20."])
AvgActualFastSess8[21]<-mean(mydata[mydata$Sess==8,"ActualFast.21."])
AvgActualFastSess8[22]<-mean(mydata[mydata$Sess==8,"ActualFast.22."])
AvgActualFastSess8[23]<-mean(mydata[mydata$Sess==8,"ActualFast.23."])
AvgActualFastSess8[24]<-mean(mydata[mydata$Sess==8,"ActualFast.24."])
AvgActualFastSess8[25]<-mean(mydata[mydata$Sess==8,"ActualFast.25."])
AvgActualSlowSess8<-numeric(25)
AvgActualSlowSess8[1]<-mean(mydata[mydata$Sess==8,"ActualSlow.1."])
AvgActualSlowSess8[2]<-mean(mydata[mydata$Sess==8,"ActualSlow.2."])
AvgActualSlowSess8[3]<-mean(mydata[mydata$Sess==8,"ActualSlow.3."])
AvgActualSlowSess8[4]<-mean(mydata[mydata$Sess==8,"ActualSlow.4."])
AvgActualSlowSess8[5]<-mean(mydata[mydata$Sess==8,"ActualSlow.5."])
AvgActualSlowSess8[6]<-mean(mydata[mydata$Sess==8,"ActualSlow.6."])
AvgActualSlowSess8[7]<-mean(mydata[mydata$Sess==8,"ActualSlow.7."])
AvgActualSlowSess8[8]<-mean(mydata[mydata$Sess==8,"ActualSlow.8."])
AvgActualSlowSess8[9]<-mean(mydata[mydata$Sess==8,"ActualSlow.9."])
AvgActualSlowSess8[10]<-mean(mydata[mydata$Sess==8,"ActualSlow.10."])
AvgActualSlowSess8[11]<-mean(mydata[mydata$Sess==8,"ActualSlow.11."])
AvgActualSlowSess8[12]<-mean(mydata[mydata$Sess==8,"ActualSlow.12."])
AvgActualSlowSess8[13]<-mean(mydata[mydata$Sess==8,"ActualSlow.13."])
AvgActualSlowSess8[14]<-mean(mydata[mydata$Sess==8,"ActualSlow.14."])
AvgActualSlowSess8[15]<-mean(mydata[mydata$Sess==8,"ActualSlow.15."])
AvgActualSlowSess8[16]<-mean(mydata[mydata$Sess==8,"ActualSlow.16."])
AvgActualSlowSess8[17]<-mean(mydata[mydata$Sess==8,"ActualSlow.17."])
AvgActualSlowSess8[18]<-mean(mydata[mydata$Sess==8,"ActualSlow.18."])
AvgActualSlowSess8[19]<-mean(mydata[mydata$Sess==8,"ActualSlow.19."])
AvgActualSlowSess8[20]<-mean(mydata[mydata$Sess==8,"ActualSlow.20."])
AvgActualSlowSess8[21]<-mean(mydata[mydata$Sess==8,"ActualSlow.21."])
AvgActualSlowSess8[22]<-mean(mydata[mydata$Sess==8,"ActualSlow.22."])
AvgActualSlowSess8[23]<-mean(mydata[mydata$Sess==8,"ActualSlow.23."])
AvgActualSlowSess8[24]<-mean(mydata[mydata$Sess==8,"ActualSlow.24."])
AvgActualSlowSess8[25]<-mean(mydata[mydata$Sess==8,"ActualSlow.25."])
AvgActualAutoSess8<-numeric(25)
AvgActualAutoSess8[1]<-mean(mydata[mydata$Sess==8,"ActualAuto.1."])
AvgActualAutoSess8[2]<-mean(mydata[mydata$Sess==8,"ActualAuto.2."])
AvgActualAutoSess8[3]<-mean(mydata[mydata$Sess==8,"ActualAuto.3."])
AvgActualAutoSess8[4]<-mean(mydata[mydata$Sess==8,"ActualAuto.4."])
AvgActualAutoSess8[5]<-mean(mydata[mydata$Sess==8,"ActualAuto.5."])
AvgActualAutoSess8[6]<-mean(mydata[mydata$Sess==8,"ActualAuto.6."])
AvgActualAutoSess8[7]<-mean(mydata[mydata$Sess==8,"ActualAuto.7."])
AvgActualAutoSess8[8]<-mean(mydata[mydata$Sess==8,"ActualAuto.8."])
AvgActualAutoSess8[9]<-mean(mydata[mydata$Sess==8,"ActualAuto.9."])
AvgActualAutoSess8[10]<-mean(mydata[mydata$Sess==8,"ActualAuto.10."])
AvgActualAutoSess8[11]<-mean(mydata[mydata$Sess==8,"ActualAuto.11."])
AvgActualAutoSess8[12]<-mean(mydata[mydata$Sess==8,"ActualAuto.12."])
AvgActualAutoSess8[13]<-mean(mydata[mydata$Sess==8,"ActualAuto.13."])
AvgActualAutoSess8[14]<-mean(mydata[mydata$Sess==8,"ActualAuto.14."])
AvgActualAutoSess8[15]<-mean(mydata[mydata$Sess==8,"ActualAuto.15."])
AvgActualAutoSess8[16]<-mean(mydata[mydata$Sess==8,"ActualAuto.16."])
AvgActualAutoSess8[17]<-mean(mydata[mydata$Sess==8,"ActualAuto.17."])
AvgActualAutoSess8[18]<-mean(mydata[mydata$Sess==8,"ActualAuto.18."])
AvgActualAutoSess8[19]<-mean(mydata[mydata$Sess==8,"ActualAuto.19."])
AvgActualAutoSess8[20]<-mean(mydata[mydata$Sess==8,"ActualAuto.20."])
AvgActualAutoSess8[21]<-mean(mydata[mydata$Sess==8,"ActualAuto.21."])
AvgActualAutoSess8[22]<-mean(mydata[mydata$Sess==8,"ActualAuto.22."])
AvgActualAutoSess8[23]<-mean(mydata[mydata$Sess==8,"ActualAuto.23."])
AvgActualAutoSess8[24]<-mean(mydata[mydata$Sess==8,"ActualAuto.24."])
AvgActualAutoSess8[25]<-mean(mydata[mydata$Sess==8,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess8, AvgActualSlowSess8, AvgActualAutoSess8)
Sess8PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess8, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess8, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess8, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 8 (Fine 3)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess8PlotActual

Auto <- jitter(AvgActualAutoSess8)
Slow <- jitter(AvgActualSlowSess8)
Fast <- jitter(AvgActualFastSess8)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess8TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess8TriActual


Auto <- jitter(AvgActualAutoSess8)
Slow <- jitter(AvgActualSlowSess8)
Fast <- jitter(AvgActualFastSess8)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess8Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 8 - Fine 3') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess8Tri2Actual


#Plot for Session 9
AvgActualFastSess9<-numeric(25)
AvgActualFastSess9[1]<-mean(mydata[mydata$Sess==9,"ActualFast.1."])
AvgActualFastSess9[2]<-mean(mydata[mydata$Sess==9,"ActualFast.2."])
AvgActualFastSess9[3]<-mean(mydata[mydata$Sess==9,"ActualFast.3."])
AvgActualFastSess9[4]<-mean(mydata[mydata$Sess==9,"ActualFast.4."])
AvgActualFastSess9[5]<-mean(mydata[mydata$Sess==9,"ActualFast.5."])
AvgActualFastSess9[6]<-mean(mydata[mydata$Sess==9,"ActualFast.6."])
AvgActualFastSess9[7]<-mean(mydata[mydata$Sess==9,"ActualFast.7."])
AvgActualFastSess9[8]<-mean(mydata[mydata$Sess==9,"ActualFast.8."])
AvgActualFastSess9[9]<-mean(mydata[mydata$Sess==9,"ActualFast.9."])
AvgActualFastSess9[10]<-mean(mydata[mydata$Sess==9,"ActualFast.10."])
AvgActualFastSess9[11]<-mean(mydata[mydata$Sess==9,"ActualFast.11."])
AvgActualFastSess9[12]<-mean(mydata[mydata$Sess==9,"ActualFast.12."])
AvgActualFastSess9[13]<-mean(mydata[mydata$Sess==9,"ActualFast.13."])
AvgActualFastSess9[14]<-mean(mydata[mydata$Sess==9,"ActualFast.14."])
AvgActualFastSess9[15]<-mean(mydata[mydata$Sess==9,"ActualFast.15."])
AvgActualFastSess9[16]<-mean(mydata[mydata$Sess==9,"ActualFast.16."])
AvgActualFastSess9[17]<-mean(mydata[mydata$Sess==9,"ActualFast.17."])
AvgActualFastSess9[18]<-mean(mydata[mydata$Sess==9,"ActualFast.18."])
AvgActualFastSess9[19]<-mean(mydata[mydata$Sess==9,"ActualFast.19."])
AvgActualFastSess9[20]<-mean(mydata[mydata$Sess==9,"ActualFast.20."])
AvgActualFastSess9[21]<-mean(mydata[mydata$Sess==9,"ActualFast.21."])
AvgActualFastSess9[22]<-mean(mydata[mydata$Sess==9,"ActualFast.22."])
AvgActualFastSess9[23]<-mean(mydata[mydata$Sess==9,"ActualFast.23."])
AvgActualFastSess9[24]<-mean(mydata[mydata$Sess==9,"ActualFast.24."])
AvgActualFastSess9[25]<-mean(mydata[mydata$Sess==9,"ActualFast.25."])
AvgActualSlowSess9<-numeric(25)
AvgActualSlowSess9[1]<-mean(mydata[mydata$Sess==9,"ActualSlow.1."])
AvgActualSlowSess9[2]<-mean(mydata[mydata$Sess==9,"ActualSlow.2."])
AvgActualSlowSess9[3]<-mean(mydata[mydata$Sess==9,"ActualSlow.3."])
AvgActualSlowSess9[4]<-mean(mydata[mydata$Sess==9,"ActualSlow.4."])
AvgActualSlowSess9[5]<-mean(mydata[mydata$Sess==9,"ActualSlow.5."])
AvgActualSlowSess9[6]<-mean(mydata[mydata$Sess==9,"ActualSlow.6."])
AvgActualSlowSess9[7]<-mean(mydata[mydata$Sess==9,"ActualSlow.7."])
AvgActualSlowSess9[8]<-mean(mydata[mydata$Sess==9,"ActualSlow.8."])
AvgActualSlowSess9[9]<-mean(mydata[mydata$Sess==9,"ActualSlow.9."])
AvgActualSlowSess9[10]<-mean(mydata[mydata$Sess==9,"ActualSlow.10."])
AvgActualSlowSess9[11]<-mean(mydata[mydata$Sess==9,"ActualSlow.11."])
AvgActualSlowSess9[12]<-mean(mydata[mydata$Sess==9,"ActualSlow.12."])
AvgActualSlowSess9[13]<-mean(mydata[mydata$Sess==9,"ActualSlow.13."])
AvgActualSlowSess9[14]<-mean(mydata[mydata$Sess==9,"ActualSlow.14."])
AvgActualSlowSess9[15]<-mean(mydata[mydata$Sess==9,"ActualSlow.15."])
AvgActualSlowSess9[16]<-mean(mydata[mydata$Sess==9,"ActualSlow.16."])
AvgActualSlowSess9[17]<-mean(mydata[mydata$Sess==9,"ActualSlow.17."])
AvgActualSlowSess9[18]<-mean(mydata[mydata$Sess==9,"ActualSlow.18."])
AvgActualSlowSess9[19]<-mean(mydata[mydata$Sess==9,"ActualSlow.19."])
AvgActualSlowSess9[20]<-mean(mydata[mydata$Sess==9,"ActualSlow.20."])
AvgActualSlowSess9[21]<-mean(mydata[mydata$Sess==9,"ActualSlow.21."])
AvgActualSlowSess9[22]<-mean(mydata[mydata$Sess==9,"ActualSlow.22."])
AvgActualSlowSess9[23]<-mean(mydata[mydata$Sess==9,"ActualSlow.23."])
AvgActualSlowSess9[24]<-mean(mydata[mydata$Sess==9,"ActualSlow.24."])
AvgActualSlowSess9[25]<-mean(mydata[mydata$Sess==9,"ActualSlow.25."])
AvgActualAutoSess9<-numeric(25)
AvgActualAutoSess9[1]<-mean(mydata[mydata$Sess==9,"ActualAuto.1."])
AvgActualAutoSess9[2]<-mean(mydata[mydata$Sess==9,"ActualAuto.2."])
AvgActualAutoSess9[3]<-mean(mydata[mydata$Sess==9,"ActualAuto.3."])
AvgActualAutoSess9[4]<-mean(mydata[mydata$Sess==9,"ActualAuto.4."])
AvgActualAutoSess9[5]<-mean(mydata[mydata$Sess==9,"ActualAuto.5."])
AvgActualAutoSess9[6]<-mean(mydata[mydata$Sess==9,"ActualAuto.6."])
AvgActualAutoSess9[7]<-mean(mydata[mydata$Sess==9,"ActualAuto.7."])
AvgActualAutoSess9[8]<-mean(mydata[mydata$Sess==9,"ActualAuto.8."])
AvgActualAutoSess9[9]<-mean(mydata[mydata$Sess==9,"ActualAuto.9."])
AvgActualAutoSess9[10]<-mean(mydata[mydata$Sess==9,"ActualAuto.10."])
AvgActualAutoSess9[11]<-mean(mydata[mydata$Sess==9,"ActualAuto.11."])
AvgActualAutoSess9[12]<-mean(mydata[mydata$Sess==9,"ActualAuto.12."])
AvgActualAutoSess9[13]<-mean(mydata[mydata$Sess==9,"ActualAuto.13."])
AvgActualAutoSess9[14]<-mean(mydata[mydata$Sess==9,"ActualAuto.14."])
AvgActualAutoSess9[15]<-mean(mydata[mydata$Sess==9,"ActualAuto.15."])
AvgActualAutoSess9[16]<-mean(mydata[mydata$Sess==9,"ActualAuto.16."])
AvgActualAutoSess9[17]<-mean(mydata[mydata$Sess==9,"ActualAuto.17."])
AvgActualAutoSess9[18]<-mean(mydata[mydata$Sess==9,"ActualAuto.18."])
AvgActualAutoSess9[19]<-mean(mydata[mydata$Sess==9,"ActualAuto.19."])
AvgActualAutoSess9[20]<-mean(mydata[mydata$Sess==9,"ActualAuto.20."])
AvgActualAutoSess9[21]<-mean(mydata[mydata$Sess==9,"ActualAuto.21."])
AvgActualAutoSess9[22]<-mean(mydata[mydata$Sess==9,"ActualAuto.22."])
AvgActualAutoSess9[23]<-mean(mydata[mydata$Sess==9,"ActualAuto.23."])
AvgActualAutoSess9[24]<-mean(mydata[mydata$Sess==9,"ActualAuto.24."])
AvgActualAutoSess9[25]<-mean(mydata[mydata$Sess==9,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess9, AvgActualSlowSess9, AvgActualAutoSess9)
Sess9PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess9, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess9, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess9, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 9 (Association 3)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess9PlotActual

Auto <- jitter(AvgActualAutoSess9)
Slow <- jitter(AvgActualSlowSess9)
Fast <- jitter(AvgActualFastSess9)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess9TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess9TriActual


Auto <- jitter(AvgActualAutoSess9)
Slow <- jitter(AvgActualSlowSess9)
Fast <- jitter(AvgActualFastSess9)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess9Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 9 - Association 3') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess9Tri2Actual


#Plot for Session 10
AvgActualFastSess10<-numeric(25)
AvgActualFastSess10[1]<-mean(mydata[mydata$Sess==10,"ActualFast.1."])
AvgActualFastSess10[2]<-mean(mydata[mydata$Sess==10,"ActualFast.2."])
AvgActualFastSess10[3]<-mean(mydata[mydata$Sess==10,"ActualFast.3."])
AvgActualFastSess10[4]<-mean(mydata[mydata$Sess==10,"ActualFast.4."])
AvgActualFastSess10[5]<-mean(mydata[mydata$Sess==10,"ActualFast.5."])
AvgActualFastSess10[6]<-mean(mydata[mydata$Sess==10,"ActualFast.6."])
AvgActualFastSess10[7]<-mean(mydata[mydata$Sess==10,"ActualFast.7."])
AvgActualFastSess10[8]<-mean(mydata[mydata$Sess==10,"ActualFast.8."])
AvgActualFastSess10[9]<-mean(mydata[mydata$Sess==10,"ActualFast.9."])
AvgActualFastSess10[10]<-mean(mydata[mydata$Sess==10,"ActualFast.10."])
AvgActualFastSess10[11]<-mean(mydata[mydata$Sess==10,"ActualFast.11."])
AvgActualFastSess10[12]<-mean(mydata[mydata$Sess==10,"ActualFast.12."])
AvgActualFastSess10[13]<-mean(mydata[mydata$Sess==10,"ActualFast.13."])
AvgActualFastSess10[14]<-mean(mydata[mydata$Sess==10,"ActualFast.14."])
AvgActualFastSess10[15]<-mean(mydata[mydata$Sess==10,"ActualFast.15."])
AvgActualFastSess10[16]<-mean(mydata[mydata$Sess==10,"ActualFast.16."])
AvgActualFastSess10[17]<-mean(mydata[mydata$Sess==10,"ActualFast.17."])
AvgActualFastSess10[18]<-mean(mydata[mydata$Sess==10,"ActualFast.18."])
AvgActualFastSess10[19]<-mean(mydata[mydata$Sess==10,"ActualFast.19."])
AvgActualFastSess10[20]<-mean(mydata[mydata$Sess==10,"ActualFast.20."])
AvgActualFastSess10[21]<-mean(mydata[mydata$Sess==10,"ActualFast.21."])
AvgActualFastSess10[22]<-mean(mydata[mydata$Sess==10,"ActualFast.22."])
AvgActualFastSess10[23]<-mean(mydata[mydata$Sess==10,"ActualFast.23."])
AvgActualFastSess10[24]<-mean(mydata[mydata$Sess==10,"ActualFast.24."])
AvgActualFastSess10[25]<-mean(mydata[mydata$Sess==10,"ActualFast.25."])
AvgActualSlowSess10<-numeric(25)
AvgActualSlowSess10[1]<-mean(mydata[mydata$Sess==10,"ActualSlow.1."])
AvgActualSlowSess10[2]<-mean(mydata[mydata$Sess==10,"ActualSlow.2."])
AvgActualSlowSess10[3]<-mean(mydata[mydata$Sess==10,"ActualSlow.3."])
AvgActualSlowSess10[4]<-mean(mydata[mydata$Sess==10,"ActualSlow.4."])
AvgActualSlowSess10[5]<-mean(mydata[mydata$Sess==10,"ActualSlow.5."])
AvgActualSlowSess10[6]<-mean(mydata[mydata$Sess==10,"ActualSlow.6."])
AvgActualSlowSess10[7]<-mean(mydata[mydata$Sess==10,"ActualSlow.7."])
AvgActualSlowSess10[8]<-mean(mydata[mydata$Sess==10,"ActualSlow.8."])
AvgActualSlowSess10[9]<-mean(mydata[mydata$Sess==10,"ActualSlow.9."])
AvgActualSlowSess10[10]<-mean(mydata[mydata$Sess==10,"ActualSlow.10."])
AvgActualSlowSess10[11]<-mean(mydata[mydata$Sess==10,"ActualSlow.11."])
AvgActualSlowSess10[12]<-mean(mydata[mydata$Sess==10,"ActualSlow.12."])
AvgActualSlowSess10[13]<-mean(mydata[mydata$Sess==10,"ActualSlow.13."])
AvgActualSlowSess10[14]<-mean(mydata[mydata$Sess==10,"ActualSlow.14."])
AvgActualSlowSess10[15]<-mean(mydata[mydata$Sess==10,"ActualSlow.15."])
AvgActualSlowSess10[16]<-mean(mydata[mydata$Sess==10,"ActualSlow.16."])
AvgActualSlowSess10[17]<-mean(mydata[mydata$Sess==10,"ActualSlow.17."])
AvgActualSlowSess10[18]<-mean(mydata[mydata$Sess==10,"ActualSlow.18."])
AvgActualSlowSess10[19]<-mean(mydata[mydata$Sess==10,"ActualSlow.19."])
AvgActualSlowSess10[20]<-mean(mydata[mydata$Sess==10,"ActualSlow.20."])
AvgActualSlowSess10[21]<-mean(mydata[mydata$Sess==10,"ActualSlow.21."])
AvgActualSlowSess10[22]<-mean(mydata[mydata$Sess==10,"ActualSlow.22."])
AvgActualSlowSess10[23]<-mean(mydata[mydata$Sess==10,"ActualSlow.23."])
AvgActualSlowSess10[24]<-mean(mydata[mydata$Sess==10,"ActualSlow.24."])
AvgActualSlowSess10[25]<-mean(mydata[mydata$Sess==10,"ActualSlow.25."])
AvgActualAutoSess10<-numeric(25)
AvgActualAutoSess10[1]<-mean(mydata[mydata$Sess==10,"ActualAuto.1."])
AvgActualAutoSess10[2]<-mean(mydata[mydata$Sess==10,"ActualAuto.2."])
AvgActualAutoSess10[3]<-mean(mydata[mydata$Sess==10,"ActualAuto.3."])
AvgActualAutoSess10[4]<-mean(mydata[mydata$Sess==10,"ActualAuto.4."])
AvgActualAutoSess10[5]<-mean(mydata[mydata$Sess==10,"ActualAuto.5."])
AvgActualAutoSess10[6]<-mean(mydata[mydata$Sess==10,"ActualAuto.6."])
AvgActualAutoSess10[7]<-mean(mydata[mydata$Sess==10,"ActualAuto.7."])
AvgActualAutoSess10[8]<-mean(mydata[mydata$Sess==10,"ActualAuto.8."])
AvgActualAutoSess10[9]<-mean(mydata[mydata$Sess==10,"ActualAuto.9."])
AvgActualAutoSess10[10]<-mean(mydata[mydata$Sess==10,"ActualAuto.10."])
AvgActualAutoSess10[11]<-mean(mydata[mydata$Sess==10,"ActualAuto.11."])
AvgActualAutoSess10[12]<-mean(mydata[mydata$Sess==10,"ActualAuto.12."])
AvgActualAutoSess10[13]<-mean(mydata[mydata$Sess==10,"ActualAuto.13."])
AvgActualAutoSess10[14]<-mean(mydata[mydata$Sess==10,"ActualAuto.14."])
AvgActualAutoSess10[15]<-mean(mydata[mydata$Sess==10,"ActualAuto.15."])
AvgActualAutoSess10[16]<-mean(mydata[mydata$Sess==10,"ActualAuto.16."])
AvgActualAutoSess10[17]<-mean(mydata[mydata$Sess==10,"ActualAuto.17."])
AvgActualAutoSess10[18]<-mean(mydata[mydata$Sess==10,"ActualAuto.18."])
AvgActualAutoSess10[19]<-mean(mydata[mydata$Sess==10,"ActualAuto.19."])
AvgActualAutoSess10[20]<-mean(mydata[mydata$Sess==10,"ActualAuto.20."])
AvgActualAutoSess10[21]<-mean(mydata[mydata$Sess==10,"ActualAuto.21."])
AvgActualAutoSess10[22]<-mean(mydata[mydata$Sess==10,"ActualAuto.22."])
AvgActualAutoSess10[23]<-mean(mydata[mydata$Sess==10,"ActualAuto.23."])
AvgActualAutoSess10[24]<-mean(mydata[mydata$Sess==10,"ActualAuto.24."])
AvgActualAutoSess10[25]<-mean(mydata[mydata$Sess==10,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess10, AvgActualSlowSess10, AvgActualAutoSess10)
Sess10PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess10, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess10, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess10, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 10 (Control 4)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess10PlotActual

Auto <- jitter(AvgActualAutoSess10)
Slow <- jitter(AvgActualSlowSess10)
Fast <- jitter(AvgActualFastSess10)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess10TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess10TriActual


Auto <- jitter(AvgActualAutoSess10)
Slow <- jitter(AvgActualSlowSess10)
Fast <- jitter(AvgActualFastSess10)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess10Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 10 - Control 4') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess10Tri2Actual



#Plot for Session 11
AvgActualFastSess11<-numeric(25)
AvgActualFastSess11[1]<-mean(mydata[mydata$Sess==11,"ActualFast.1."])
AvgActualFastSess11[2]<-mean(mydata[mydata$Sess==11,"ActualFast.2."])
AvgActualFastSess11[3]<-mean(mydata[mydata$Sess==11,"ActualFast.3."])
AvgActualFastSess11[4]<-mean(mydata[mydata$Sess==11,"ActualFast.4."])
AvgActualFastSess11[5]<-mean(mydata[mydata$Sess==11,"ActualFast.5."])
AvgActualFastSess11[6]<-mean(mydata[mydata$Sess==11,"ActualFast.6."])
AvgActualFastSess11[7]<-mean(mydata[mydata$Sess==11,"ActualFast.7."])
AvgActualFastSess11[8]<-mean(mydata[mydata$Sess==11,"ActualFast.8."])
AvgActualFastSess11[9]<-mean(mydata[mydata$Sess==11,"ActualFast.9."])
AvgActualFastSess11[10]<-mean(mydata[mydata$Sess==11,"ActualFast.10."])
AvgActualFastSess11[11]<-mean(mydata[mydata$Sess==11,"ActualFast.11."])
AvgActualFastSess11[12]<-mean(mydata[mydata$Sess==11,"ActualFast.12."])
AvgActualFastSess11[13]<-mean(mydata[mydata$Sess==11,"ActualFast.13."])
AvgActualFastSess11[14]<-mean(mydata[mydata$Sess==11,"ActualFast.14."])
AvgActualFastSess11[15]<-mean(mydata[mydata$Sess==11,"ActualFast.15."])
AvgActualFastSess11[16]<-mean(mydata[mydata$Sess==11,"ActualFast.16."])
AvgActualFastSess11[17]<-mean(mydata[mydata$Sess==11,"ActualFast.17."])
AvgActualFastSess11[18]<-mean(mydata[mydata$Sess==11,"ActualFast.18."])
AvgActualFastSess11[19]<-mean(mydata[mydata$Sess==11,"ActualFast.19."])
AvgActualFastSess11[20]<-mean(mydata[mydata$Sess==11,"ActualFast.20."])
AvgActualFastSess11[21]<-mean(mydata[mydata$Sess==11,"ActualFast.21."])
AvgActualFastSess11[22]<-mean(mydata[mydata$Sess==11,"ActualFast.22."])
AvgActualFastSess11[23]<-mean(mydata[mydata$Sess==11,"ActualFast.23."])
AvgActualFastSess11[24]<-mean(mydata[mydata$Sess==11,"ActualFast.24."])
AvgActualFastSess11[25]<-mean(mydata[mydata$Sess==11,"ActualFast.25."])
AvgActualSlowSess11<-numeric(25)
AvgActualSlowSess11[1]<-mean(mydata[mydata$Sess==11,"ActualSlow.1."])
AvgActualSlowSess11[2]<-mean(mydata[mydata$Sess==11,"ActualSlow.2."])
AvgActualSlowSess11[3]<-mean(mydata[mydata$Sess==11,"ActualSlow.3."])
AvgActualSlowSess11[4]<-mean(mydata[mydata$Sess==11,"ActualSlow.4."])
AvgActualSlowSess11[5]<-mean(mydata[mydata$Sess==11,"ActualSlow.5."])
AvgActualSlowSess11[6]<-mean(mydata[mydata$Sess==11,"ActualSlow.6."])
AvgActualSlowSess11[7]<-mean(mydata[mydata$Sess==11,"ActualSlow.7."])
AvgActualSlowSess11[8]<-mean(mydata[mydata$Sess==11,"ActualSlow.8."])
AvgActualSlowSess11[9]<-mean(mydata[mydata$Sess==11,"ActualSlow.9."])
AvgActualSlowSess11[10]<-mean(mydata[mydata$Sess==11,"ActualSlow.10."])
AvgActualSlowSess11[11]<-mean(mydata[mydata$Sess==11,"ActualSlow.11."])
AvgActualSlowSess11[12]<-mean(mydata[mydata$Sess==11,"ActualSlow.12."])
AvgActualSlowSess11[13]<-mean(mydata[mydata$Sess==11,"ActualSlow.13."])
AvgActualSlowSess11[14]<-mean(mydata[mydata$Sess==11,"ActualSlow.14."])
AvgActualSlowSess11[15]<-mean(mydata[mydata$Sess==11,"ActualSlow.15."])
AvgActualSlowSess11[16]<-mean(mydata[mydata$Sess==11,"ActualSlow.16."])
AvgActualSlowSess11[17]<-mean(mydata[mydata$Sess==11,"ActualSlow.17."])
AvgActualSlowSess11[18]<-mean(mydata[mydata$Sess==11,"ActualSlow.18."])
AvgActualSlowSess11[19]<-mean(mydata[mydata$Sess==11,"ActualSlow.19."])
AvgActualSlowSess11[20]<-mean(mydata[mydata$Sess==11,"ActualSlow.20."])
AvgActualSlowSess11[21]<-mean(mydata[mydata$Sess==11,"ActualSlow.21."])
AvgActualSlowSess11[22]<-mean(mydata[mydata$Sess==11,"ActualSlow.22."])
AvgActualSlowSess11[23]<-mean(mydata[mydata$Sess==11,"ActualSlow.23."])
AvgActualSlowSess11[24]<-mean(mydata[mydata$Sess==11,"ActualSlow.24."])
AvgActualSlowSess11[25]<-mean(mydata[mydata$Sess==11,"ActualSlow.25."])
AvgActualAutoSess11<-numeric(25)
AvgActualAutoSess11[1]<-mean(mydata[mydata$Sess==11,"ActualAuto.1."])
AvgActualAutoSess11[2]<-mean(mydata[mydata$Sess==11,"ActualAuto.2."])
AvgActualAutoSess11[3]<-mean(mydata[mydata$Sess==11,"ActualAuto.3."])
AvgActualAutoSess11[4]<-mean(mydata[mydata$Sess==11,"ActualAuto.4."])
AvgActualAutoSess11[5]<-mean(mydata[mydata$Sess==11,"ActualAuto.5."])
AvgActualAutoSess11[6]<-mean(mydata[mydata$Sess==11,"ActualAuto.6."])
AvgActualAutoSess11[7]<-mean(mydata[mydata$Sess==11,"ActualAuto.7."])
AvgActualAutoSess11[8]<-mean(mydata[mydata$Sess==11,"ActualAuto.8."])
AvgActualAutoSess11[9]<-mean(mydata[mydata$Sess==11,"ActualAuto.9."])
AvgActualAutoSess11[10]<-mean(mydata[mydata$Sess==11,"ActualAuto.10."])
AvgActualAutoSess11[11]<-mean(mydata[mydata$Sess==11,"ActualAuto.11."])
AvgActualAutoSess11[12]<-mean(mydata[mydata$Sess==11,"ActualAuto.12."])
AvgActualAutoSess11[13]<-mean(mydata[mydata$Sess==11,"ActualAuto.13."])
AvgActualAutoSess11[14]<-mean(mydata[mydata$Sess==11,"ActualAuto.14."])
AvgActualAutoSess11[15]<-mean(mydata[mydata$Sess==11,"ActualAuto.15."])
AvgActualAutoSess11[16]<-mean(mydata[mydata$Sess==11,"ActualAuto.16."])
AvgActualAutoSess11[17]<-mean(mydata[mydata$Sess==11,"ActualAuto.17."])
AvgActualAutoSess11[18]<-mean(mydata[mydata$Sess==11,"ActualAuto.18."])
AvgActualAutoSess11[19]<-mean(mydata[mydata$Sess==11,"ActualAuto.19."])
AvgActualAutoSess11[20]<-mean(mydata[mydata$Sess==11,"ActualAuto.20."])
AvgActualAutoSess11[21]<-mean(mydata[mydata$Sess==11,"ActualAuto.21."])
AvgActualAutoSess11[22]<-mean(mydata[mydata$Sess==11,"ActualAuto.22."])
AvgActualAutoSess11[23]<-mean(mydata[mydata$Sess==11,"ActualAuto.23."])
AvgActualAutoSess11[24]<-mean(mydata[mydata$Sess==11,"ActualAuto.24."])
AvgActualAutoSess11[25]<-mean(mydata[mydata$Sess==11,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess11, AvgActualSlowSess11, AvgActualAutoSess11)
Sess11PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess11, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess11, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess11, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 11 (Association 4)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess11PlotActual

Auto <- jitter(AvgActualAutoSess11)
Slow <- jitter(AvgActualSlowSess11)
Fast <- jitter(AvgActualFastSess11)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess11TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess11TriActual


Auto <- jitter(AvgActualAutoSess11)
Slow <- jitter(AvgActualSlowSess11)
Fast <- jitter(AvgActualFastSess11)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess11Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 11 - Association 4') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess11Tri2Actual



#Plot for Session 12
AvgActualFastSess12<-numeric(25)
AvgActualFastSess12[1]<-mean(mydata[mydata$Sess==12,"ActualFast.1."])
AvgActualFastSess12[2]<-mean(mydata[mydata$Sess==12,"ActualFast.2."])
AvgActualFastSess12[3]<-mean(mydata[mydata$Sess==12,"ActualFast.3."])
AvgActualFastSess12[4]<-mean(mydata[mydata$Sess==12,"ActualFast.4."])
AvgActualFastSess12[5]<-mean(mydata[mydata$Sess==12,"ActualFast.5."])
AvgActualFastSess12[6]<-mean(mydata[mydata$Sess==12,"ActualFast.6."])
AvgActualFastSess12[7]<-mean(mydata[mydata$Sess==12,"ActualFast.7."])
AvgActualFastSess12[8]<-mean(mydata[mydata$Sess==12,"ActualFast.8."])
AvgActualFastSess12[9]<-mean(mydata[mydata$Sess==12,"ActualFast.9."])
AvgActualFastSess12[10]<-mean(mydata[mydata$Sess==12,"ActualFast.10."])
AvgActualFastSess12[11]<-mean(mydata[mydata$Sess==12,"ActualFast.11."])
AvgActualFastSess12[12]<-mean(mydata[mydata$Sess==12,"ActualFast.12."])
AvgActualFastSess12[13]<-mean(mydata[mydata$Sess==12,"ActualFast.13."])
AvgActualFastSess12[14]<-mean(mydata[mydata$Sess==12,"ActualFast.14."])
AvgActualFastSess12[15]<-mean(mydata[mydata$Sess==12,"ActualFast.15."])
AvgActualFastSess12[16]<-mean(mydata[mydata$Sess==12,"ActualFast.16."])
AvgActualFastSess12[17]<-mean(mydata[mydata$Sess==12,"ActualFast.17."])
AvgActualFastSess12[18]<-mean(mydata[mydata$Sess==12,"ActualFast.18."])
AvgActualFastSess12[19]<-mean(mydata[mydata$Sess==12,"ActualFast.19."])
AvgActualFastSess12[20]<-mean(mydata[mydata$Sess==12,"ActualFast.20."])
AvgActualFastSess12[21]<-mean(mydata[mydata$Sess==12,"ActualFast.21."])
AvgActualFastSess12[22]<-mean(mydata[mydata$Sess==12,"ActualFast.22."])
AvgActualFastSess12[23]<-mean(mydata[mydata$Sess==12,"ActualFast.23."])
AvgActualFastSess12[24]<-mean(mydata[mydata$Sess==12,"ActualFast.24."])
AvgActualFastSess12[25]<-mean(mydata[mydata$Sess==12,"ActualFast.25."])
AvgActualSlowSess12<-numeric(25)
AvgActualSlowSess12[1]<-mean(mydata[mydata$Sess==12,"ActualSlow.1."])
AvgActualSlowSess12[2]<-mean(mydata[mydata$Sess==12,"ActualSlow.2."])
AvgActualSlowSess12[3]<-mean(mydata[mydata$Sess==12,"ActualSlow.3."])
AvgActualSlowSess12[4]<-mean(mydata[mydata$Sess==12,"ActualSlow.4."])
AvgActualSlowSess12[5]<-mean(mydata[mydata$Sess==12,"ActualSlow.5."])
AvgActualSlowSess12[6]<-mean(mydata[mydata$Sess==12,"ActualSlow.6."])
AvgActualSlowSess12[7]<-mean(mydata[mydata$Sess==12,"ActualSlow.7."])
AvgActualSlowSess12[8]<-mean(mydata[mydata$Sess==12,"ActualSlow.8."])
AvgActualSlowSess12[9]<-mean(mydata[mydata$Sess==12,"ActualSlow.9."])
AvgActualSlowSess12[10]<-mean(mydata[mydata$Sess==12,"ActualSlow.10."])
AvgActualSlowSess12[11]<-mean(mydata[mydata$Sess==12,"ActualSlow.11."])
AvgActualSlowSess12[12]<-mean(mydata[mydata$Sess==12,"ActualSlow.12."])
AvgActualSlowSess12[13]<-mean(mydata[mydata$Sess==12,"ActualSlow.13."])
AvgActualSlowSess12[14]<-mean(mydata[mydata$Sess==12,"ActualSlow.14."])
AvgActualSlowSess12[15]<-mean(mydata[mydata$Sess==12,"ActualSlow.15."])
AvgActualSlowSess12[16]<-mean(mydata[mydata$Sess==12,"ActualSlow.16."])
AvgActualSlowSess12[17]<-mean(mydata[mydata$Sess==12,"ActualSlow.17."])
AvgActualSlowSess12[18]<-mean(mydata[mydata$Sess==12,"ActualSlow.18."])
AvgActualSlowSess12[19]<-mean(mydata[mydata$Sess==12,"ActualSlow.19."])
AvgActualSlowSess12[20]<-mean(mydata[mydata$Sess==12,"ActualSlow.20."])
AvgActualSlowSess12[21]<-mean(mydata[mydata$Sess==12,"ActualSlow.21."])
AvgActualSlowSess12[22]<-mean(mydata[mydata$Sess==12,"ActualSlow.22."])
AvgActualSlowSess12[23]<-mean(mydata[mydata$Sess==12,"ActualSlow.23."])
AvgActualSlowSess12[24]<-mean(mydata[mydata$Sess==12,"ActualSlow.24."])
AvgActualSlowSess12[25]<-mean(mydata[mydata$Sess==12,"ActualSlow.25."])
AvgActualAutoSess12<-numeric(25)
AvgActualAutoSess12[1]<-mean(mydata[mydata$Sess==12,"ActualAuto.1."])
AvgActualAutoSess12[2]<-mean(mydata[mydata$Sess==12,"ActualAuto.2."])
AvgActualAutoSess12[3]<-mean(mydata[mydata$Sess==12,"ActualAuto.3."])
AvgActualAutoSess12[4]<-mean(mydata[mydata$Sess==12,"ActualAuto.4."])
AvgActualAutoSess12[5]<-mean(mydata[mydata$Sess==12,"ActualAuto.5."])
AvgActualAutoSess12[6]<-mean(mydata[mydata$Sess==12,"ActualAuto.6."])
AvgActualAutoSess12[7]<-mean(mydata[mydata$Sess==12,"ActualAuto.7."])
AvgActualAutoSess12[8]<-mean(mydata[mydata$Sess==12,"ActualAuto.8."])
AvgActualAutoSess12[9]<-mean(mydata[mydata$Sess==12,"ActualAuto.9."])
AvgActualAutoSess12[10]<-mean(mydata[mydata$Sess==12,"ActualAuto.10."])
AvgActualAutoSess12[11]<-mean(mydata[mydata$Sess==12,"ActualAuto.11."])
AvgActualAutoSess12[12]<-mean(mydata[mydata$Sess==12,"ActualAuto.12."])
AvgActualAutoSess12[13]<-mean(mydata[mydata$Sess==12,"ActualAuto.13."])
AvgActualAutoSess12[14]<-mean(mydata[mydata$Sess==12,"ActualAuto.14."])
AvgActualAutoSess12[15]<-mean(mydata[mydata$Sess==12,"ActualAuto.15."])
AvgActualAutoSess12[16]<-mean(mydata[mydata$Sess==12,"ActualAuto.16."])
AvgActualAutoSess12[17]<-mean(mydata[mydata$Sess==12,"ActualAuto.17."])
AvgActualAutoSess12[18]<-mean(mydata[mydata$Sess==12,"ActualAuto.18."])
AvgActualAutoSess12[19]<-mean(mydata[mydata$Sess==12,"ActualAuto.19."])
AvgActualAutoSess12[20]<-mean(mydata[mydata$Sess==12,"ActualAuto.20."])
AvgActualAutoSess12[21]<-mean(mydata[mydata$Sess==12,"ActualAuto.21."])
AvgActualAutoSess12[22]<-mean(mydata[mydata$Sess==12,"ActualAuto.22."])
AvgActualAutoSess12[23]<-mean(mydata[mydata$Sess==12,"ActualAuto.23."])
AvgActualAutoSess12[24]<-mean(mydata[mydata$Sess==12,"ActualAuto.24."])
AvgActualAutoSess12[25]<-mean(mydata[mydata$Sess==12,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess12, AvgActualSlowSess12, AvgActualAutoSess12)
Sess12PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess12, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess12, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess12, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 12 (Fine 4)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess12PlotActual

Auto <- jitter(AvgActualAutoSess12)
Slow <- jitter(AvgActualSlowSess12)
Fast <- jitter(AvgActualFastSess12)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess12TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess12TriActual


Auto <- jitter(AvgActualAutoSess12)
Slow <- jitter(AvgActualSlowSess12)
Fast <- jitter(AvgActualFastSess12)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess12Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 12 - Fine 4') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess12Tri2Actual


#Plot for Session 13
AvgActualFastSess13<-numeric(25)
AvgActualFastSess13[1]<-mean(mydata[mydata$Sess==13,"ActualFast.1."])
AvgActualFastSess13[2]<-mean(mydata[mydata$Sess==13,"ActualFast.2."])
AvgActualFastSess13[3]<-mean(mydata[mydata$Sess==13,"ActualFast.3."])
AvgActualFastSess13[4]<-mean(mydata[mydata$Sess==13,"ActualFast.4."])
AvgActualFastSess13[5]<-mean(mydata[mydata$Sess==13,"ActualFast.5."])
AvgActualFastSess13[6]<-mean(mydata[mydata$Sess==13,"ActualFast.6."])
AvgActualFastSess13[7]<-mean(mydata[mydata$Sess==13,"ActualFast.7."])
AvgActualFastSess13[8]<-mean(mydata[mydata$Sess==13,"ActualFast.8."])
AvgActualFastSess13[9]<-mean(mydata[mydata$Sess==13,"ActualFast.9."])
AvgActualFastSess13[10]<-mean(mydata[mydata$Sess==13,"ActualFast.10."])
AvgActualFastSess13[11]<-mean(mydata[mydata$Sess==13,"ActualFast.11."])
AvgActualFastSess13[12]<-mean(mydata[mydata$Sess==13,"ActualFast.12."])
AvgActualFastSess13[13]<-mean(mydata[mydata$Sess==13,"ActualFast.13."])
AvgActualFastSess13[14]<-mean(mydata[mydata$Sess==13,"ActualFast.14."])
AvgActualFastSess13[15]<-mean(mydata[mydata$Sess==13,"ActualFast.15."])
AvgActualFastSess13[16]<-mean(mydata[mydata$Sess==13,"ActualFast.16."])
AvgActualFastSess13[17]<-mean(mydata[mydata$Sess==13,"ActualFast.17."])
AvgActualFastSess13[18]<-mean(mydata[mydata$Sess==13,"ActualFast.18."])
AvgActualFastSess13[19]<-mean(mydata[mydata$Sess==13,"ActualFast.19."])
AvgActualFastSess13[20]<-mean(mydata[mydata$Sess==13,"ActualFast.20."])
AvgActualFastSess13[21]<-mean(mydata[mydata$Sess==13,"ActualFast.21."])
AvgActualFastSess13[22]<-mean(mydata[mydata$Sess==13,"ActualFast.22."])
AvgActualFastSess13[23]<-mean(mydata[mydata$Sess==13,"ActualFast.23."])
AvgActualFastSess13[24]<-mean(mydata[mydata$Sess==13,"ActualFast.24."])
AvgActualFastSess13[25]<-mean(mydata[mydata$Sess==13,"ActualFast.25."])
AvgActualSlowSess13<-numeric(25)
AvgActualSlowSess13[1]<-mean(mydata[mydata$Sess==13,"ActualSlow.1."])
AvgActualSlowSess13[2]<-mean(mydata[mydata$Sess==13,"ActualSlow.2."])
AvgActualSlowSess13[3]<-mean(mydata[mydata$Sess==13,"ActualSlow.3."])
AvgActualSlowSess13[4]<-mean(mydata[mydata$Sess==13,"ActualSlow.4."])
AvgActualSlowSess13[5]<-mean(mydata[mydata$Sess==13,"ActualSlow.5."])
AvgActualSlowSess13[6]<-mean(mydata[mydata$Sess==13,"ActualSlow.6."])
AvgActualSlowSess13[7]<-mean(mydata[mydata$Sess==13,"ActualSlow.7."])
AvgActualSlowSess13[8]<-mean(mydata[mydata$Sess==13,"ActualSlow.8."])
AvgActualSlowSess13[9]<-mean(mydata[mydata$Sess==13,"ActualSlow.9."])
AvgActualSlowSess13[10]<-mean(mydata[mydata$Sess==13,"ActualSlow.10."])
AvgActualSlowSess13[11]<-mean(mydata[mydata$Sess==13,"ActualSlow.11."])
AvgActualSlowSess13[12]<-mean(mydata[mydata$Sess==13,"ActualSlow.12."])
AvgActualSlowSess13[13]<-mean(mydata[mydata$Sess==13,"ActualSlow.13."])
AvgActualSlowSess13[14]<-mean(mydata[mydata$Sess==13,"ActualSlow.14."])
AvgActualSlowSess13[15]<-mean(mydata[mydata$Sess==13,"ActualSlow.15."])
AvgActualSlowSess13[16]<-mean(mydata[mydata$Sess==13,"ActualSlow.16."])
AvgActualSlowSess13[17]<-mean(mydata[mydata$Sess==13,"ActualSlow.17."])
AvgActualSlowSess13[18]<-mean(mydata[mydata$Sess==13,"ActualSlow.18."])
AvgActualSlowSess13[19]<-mean(mydata[mydata$Sess==13,"ActualSlow.19."])
AvgActualSlowSess13[20]<-mean(mydata[mydata$Sess==13,"ActualSlow.20."])
AvgActualSlowSess13[21]<-mean(mydata[mydata$Sess==13,"ActualSlow.21."])
AvgActualSlowSess13[22]<-mean(mydata[mydata$Sess==13,"ActualSlow.22."])
AvgActualSlowSess13[23]<-mean(mydata[mydata$Sess==13,"ActualSlow.23."])
AvgActualSlowSess13[24]<-mean(mydata[mydata$Sess==13,"ActualSlow.24."])
AvgActualSlowSess13[25]<-mean(mydata[mydata$Sess==13,"ActualSlow.25."])
AvgActualAutoSess13<-numeric(25)
AvgActualAutoSess13[1]<-mean(mydata[mydata$Sess==13,"ActualAuto.1."])
AvgActualAutoSess13[2]<-mean(mydata[mydata$Sess==13,"ActualAuto.2."])
AvgActualAutoSess13[3]<-mean(mydata[mydata$Sess==13,"ActualAuto.3."])
AvgActualAutoSess13[4]<-mean(mydata[mydata$Sess==13,"ActualAuto.4."])
AvgActualAutoSess13[5]<-mean(mydata[mydata$Sess==13,"ActualAuto.5."])
AvgActualAutoSess13[6]<-mean(mydata[mydata$Sess==13,"ActualAuto.6."])
AvgActualAutoSess13[7]<-mean(mydata[mydata$Sess==13,"ActualAuto.7."])
AvgActualAutoSess13[8]<-mean(mydata[mydata$Sess==13,"ActualAuto.8."])
AvgActualAutoSess13[9]<-mean(mydata[mydata$Sess==13,"ActualAuto.9."])
AvgActualAutoSess13[10]<-mean(mydata[mydata$Sess==13,"ActualAuto.10."])
AvgActualAutoSess13[11]<-mean(mydata[mydata$Sess==13,"ActualAuto.11."])
AvgActualAutoSess13[12]<-mean(mydata[mydata$Sess==13,"ActualAuto.12."])
AvgActualAutoSess13[13]<-mean(mydata[mydata$Sess==13,"ActualAuto.13."])
AvgActualAutoSess13[14]<-mean(mydata[mydata$Sess==13,"ActualAuto.14."])
AvgActualAutoSess13[15]<-mean(mydata[mydata$Sess==13,"ActualAuto.15."])
AvgActualAutoSess13[16]<-mean(mydata[mydata$Sess==13,"ActualAuto.16."])
AvgActualAutoSess13[17]<-mean(mydata[mydata$Sess==13,"ActualAuto.17."])
AvgActualAutoSess13[18]<-mean(mydata[mydata$Sess==13,"ActualAuto.18."])
AvgActualAutoSess13[19]<-mean(mydata[mydata$Sess==13,"ActualAuto.19."])
AvgActualAutoSess13[20]<-mean(mydata[mydata$Sess==13,"ActualAuto.20."])
AvgActualAutoSess13[21]<-mean(mydata[mydata$Sess==13,"ActualAuto.21."])
AvgActualAutoSess13[22]<-mean(mydata[mydata$Sess==13,"ActualAuto.22."])
AvgActualAutoSess13[23]<-mean(mydata[mydata$Sess==13,"ActualAuto.23."])
AvgActualAutoSess13[24]<-mean(mydata[mydata$Sess==13,"ActualAuto.24."])
AvgActualAutoSess13[25]<-mean(mydata[mydata$Sess==13,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess13, AvgActualSlowSess13, AvgActualAutoSess13)
Sess13PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess13, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess13, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess13, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 13 (Association 5)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess13PlotActual

Auto <- jitter(AvgActualAutoSess13)
Slow <- jitter(AvgActualSlowSess13)
Fast <- jitter(AvgActualFastSess13)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess13TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess13TriActual


Auto <- jitter(AvgActualAutoSess13)
Slow <- jitter(AvgActualSlowSess13)
Fast <- jitter(AvgActualFastSess13)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess13Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 13 - Association 5') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess13Tri2Actual

#Plot for Session 14
AvgActualFastSess14<-numeric(25)
AvgActualFastSess14[1]<-mean(mydata[mydata$Sess==14,"ActualFast.1."])
AvgActualFastSess14[2]<-mean(mydata[mydata$Sess==14,"ActualFast.2."])
AvgActualFastSess14[3]<-mean(mydata[mydata$Sess==14,"ActualFast.3."])
AvgActualFastSess14[4]<-mean(mydata[mydata$Sess==14,"ActualFast.4."])
AvgActualFastSess14[5]<-mean(mydata[mydata$Sess==14,"ActualFast.5."])
AvgActualFastSess14[6]<-mean(mydata[mydata$Sess==14,"ActualFast.6."])
AvgActualFastSess14[7]<-mean(mydata[mydata$Sess==14,"ActualFast.7."])
AvgActualFastSess14[8]<-mean(mydata[mydata$Sess==14,"ActualFast.8."])
AvgActualFastSess14[9]<-mean(mydata[mydata$Sess==14,"ActualFast.9."])
AvgActualFastSess14[10]<-mean(mydata[mydata$Sess==14,"ActualFast.10."])
AvgActualFastSess14[11]<-mean(mydata[mydata$Sess==14,"ActualFast.11."])
AvgActualFastSess14[12]<-mean(mydata[mydata$Sess==14,"ActualFast.12."])
AvgActualFastSess14[13]<-mean(mydata[mydata$Sess==14,"ActualFast.13."])
AvgActualFastSess14[14]<-mean(mydata[mydata$Sess==14,"ActualFast.14."])
AvgActualFastSess14[15]<-mean(mydata[mydata$Sess==14,"ActualFast.15."])
AvgActualFastSess14[16]<-mean(mydata[mydata$Sess==14,"ActualFast.16."])
AvgActualFastSess14[17]<-mean(mydata[mydata$Sess==14,"ActualFast.17."])
AvgActualFastSess14[18]<-mean(mydata[mydata$Sess==14,"ActualFast.18."])
AvgActualFastSess14[19]<-mean(mydata[mydata$Sess==14,"ActualFast.19."])
AvgActualFastSess14[20]<-mean(mydata[mydata$Sess==14,"ActualFast.20."])
AvgActualFastSess14[21]<-mean(mydata[mydata$Sess==14,"ActualFast.21."])
AvgActualFastSess14[22]<-mean(mydata[mydata$Sess==14,"ActualFast.22."])
AvgActualFastSess14[23]<-mean(mydata[mydata$Sess==14,"ActualFast.23."])
AvgActualFastSess14[24]<-mean(mydata[mydata$Sess==14,"ActualFast.24."])
AvgActualFastSess14[25]<-mean(mydata[mydata$Sess==14,"ActualFast.25."])
AvgActualSlowSess14<-numeric(25)
AvgActualSlowSess14[1]<-mean(mydata[mydata$Sess==14,"ActualSlow.1."])
AvgActualSlowSess14[2]<-mean(mydata[mydata$Sess==14,"ActualSlow.2."])
AvgActualSlowSess14[3]<-mean(mydata[mydata$Sess==14,"ActualSlow.3."])
AvgActualSlowSess14[4]<-mean(mydata[mydata$Sess==14,"ActualSlow.4."])
AvgActualSlowSess14[5]<-mean(mydata[mydata$Sess==14,"ActualSlow.5."])
AvgActualSlowSess14[6]<-mean(mydata[mydata$Sess==14,"ActualSlow.6."])
AvgActualSlowSess14[7]<-mean(mydata[mydata$Sess==14,"ActualSlow.7."])
AvgActualSlowSess14[8]<-mean(mydata[mydata$Sess==14,"ActualSlow.8."])
AvgActualSlowSess14[9]<-mean(mydata[mydata$Sess==14,"ActualSlow.9."])
AvgActualSlowSess14[10]<-mean(mydata[mydata$Sess==14,"ActualSlow.10."])
AvgActualSlowSess14[11]<-mean(mydata[mydata$Sess==14,"ActualSlow.11."])
AvgActualSlowSess14[12]<-mean(mydata[mydata$Sess==14,"ActualSlow.12."])
AvgActualSlowSess14[13]<-mean(mydata[mydata$Sess==14,"ActualSlow.13."])
AvgActualSlowSess14[14]<-mean(mydata[mydata$Sess==14,"ActualSlow.14."])
AvgActualSlowSess14[15]<-mean(mydata[mydata$Sess==14,"ActualSlow.15."])
AvgActualSlowSess14[16]<-mean(mydata[mydata$Sess==14,"ActualSlow.16."])
AvgActualSlowSess14[17]<-mean(mydata[mydata$Sess==14,"ActualSlow.17."])
AvgActualSlowSess14[18]<-mean(mydata[mydata$Sess==14,"ActualSlow.18."])
AvgActualSlowSess14[19]<-mean(mydata[mydata$Sess==14,"ActualSlow.19."])
AvgActualSlowSess14[20]<-mean(mydata[mydata$Sess==14,"ActualSlow.20."])
AvgActualSlowSess14[21]<-mean(mydata[mydata$Sess==14,"ActualSlow.21."])
AvgActualSlowSess14[22]<-mean(mydata[mydata$Sess==14,"ActualSlow.22."])
AvgActualSlowSess14[23]<-mean(mydata[mydata$Sess==14,"ActualSlow.23."])
AvgActualSlowSess14[24]<-mean(mydata[mydata$Sess==14,"ActualSlow.24."])
AvgActualSlowSess14[25]<-mean(mydata[mydata$Sess==14,"ActualSlow.25."])
AvgActualAutoSess14<-numeric(25)
AvgActualAutoSess14[1]<-mean(mydata[mydata$Sess==14,"ActualAuto.1."])
AvgActualAutoSess14[2]<-mean(mydata[mydata$Sess==14,"ActualAuto.2."])
AvgActualAutoSess14[3]<-mean(mydata[mydata$Sess==14,"ActualAuto.3."])
AvgActualAutoSess14[4]<-mean(mydata[mydata$Sess==14,"ActualAuto.4."])
AvgActualAutoSess14[5]<-mean(mydata[mydata$Sess==14,"ActualAuto.5."])
AvgActualAutoSess14[6]<-mean(mydata[mydata$Sess==14,"ActualAuto.6."])
AvgActualAutoSess14[7]<-mean(mydata[mydata$Sess==14,"ActualAuto.7."])
AvgActualAutoSess14[8]<-mean(mydata[mydata$Sess==14,"ActualAuto.8."])
AvgActualAutoSess14[9]<-mean(mydata[mydata$Sess==14,"ActualAuto.9."])
AvgActualAutoSess14[10]<-mean(mydata[mydata$Sess==14,"ActualAuto.10."])
AvgActualAutoSess14[11]<-mean(mydata[mydata$Sess==14,"ActualAuto.11."])
AvgActualAutoSess14[12]<-mean(mydata[mydata$Sess==14,"ActualAuto.12."])
AvgActualAutoSess14[13]<-mean(mydata[mydata$Sess==14,"ActualAuto.13."])
AvgActualAutoSess14[14]<-mean(mydata[mydata$Sess==14,"ActualAuto.14."])
AvgActualAutoSess14[15]<-mean(mydata[mydata$Sess==14,"ActualAuto.15."])
AvgActualAutoSess14[16]<-mean(mydata[mydata$Sess==14,"ActualAuto.16."])
AvgActualAutoSess14[17]<-mean(mydata[mydata$Sess==14,"ActualAuto.17."])
AvgActualAutoSess14[18]<-mean(mydata[mydata$Sess==14,"ActualAuto.18."])
AvgActualAutoSess14[19]<-mean(mydata[mydata$Sess==14,"ActualAuto.19."])
AvgActualAutoSess14[20]<-mean(mydata[mydata$Sess==14,"ActualAuto.20."])
AvgActualAutoSess14[21]<-mean(mydata[mydata$Sess==14,"ActualAuto.21."])
AvgActualAutoSess14[22]<-mean(mydata[mydata$Sess==14,"ActualAuto.22."])
AvgActualAutoSess14[23]<-mean(mydata[mydata$Sess==14,"ActualAuto.23."])
AvgActualAutoSess14[24]<-mean(mydata[mydata$Sess==14,"ActualAuto.24."])
AvgActualAutoSess14[25]<-mean(mydata[mydata$Sess==14,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess14, AvgActualSlowSess14, AvgActualAutoSess14)
Sess14PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess14, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess14, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess14, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 14 (Control 5)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess14PlotActual

Auto <- jitter(AvgActualAutoSess14)
Slow <- jitter(AvgActualSlowSess14)
Fast <- jitter(AvgActualFastSess14)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess14TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess14TriActual


Auto <- jitter(AvgActualAutoSess14)
Slow <- jitter(AvgActualSlowSess14)
Fast <- jitter(AvgActualFastSess14)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess14Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 14 - Control 5') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess14Tri2Actual


#Plot for Session 15
AvgActualFastSess15<-numeric(25)
AvgActualFastSess15[1]<-mean(mydata[mydata$Sess==15,"ActualFast.1."])
AvgActualFastSess15[2]<-mean(mydata[mydata$Sess==15,"ActualFast.2."])
AvgActualFastSess15[3]<-mean(mydata[mydata$Sess==15,"ActualFast.3."])
AvgActualFastSess15[4]<-mean(mydata[mydata$Sess==15,"ActualFast.4."])
AvgActualFastSess15[5]<-mean(mydata[mydata$Sess==15,"ActualFast.5."])
AvgActualFastSess15[6]<-mean(mydata[mydata$Sess==15,"ActualFast.6."])
AvgActualFastSess15[7]<-mean(mydata[mydata$Sess==15,"ActualFast.7."])
AvgActualFastSess15[8]<-mean(mydata[mydata$Sess==15,"ActualFast.8."])
AvgActualFastSess15[9]<-mean(mydata[mydata$Sess==15,"ActualFast.9."])
AvgActualFastSess15[10]<-mean(mydata[mydata$Sess==15,"ActualFast.10."])
AvgActualFastSess15[11]<-mean(mydata[mydata$Sess==15,"ActualFast.11."])
AvgActualFastSess15[12]<-mean(mydata[mydata$Sess==15,"ActualFast.12."])
AvgActualFastSess15[13]<-mean(mydata[mydata$Sess==15,"ActualFast.13."])
AvgActualFastSess15[14]<-mean(mydata[mydata$Sess==15,"ActualFast.14."])
AvgActualFastSess15[15]<-mean(mydata[mydata$Sess==15,"ActualFast.15."])
AvgActualFastSess15[16]<-mean(mydata[mydata$Sess==15,"ActualFast.16."])
AvgActualFastSess15[17]<-mean(mydata[mydata$Sess==15,"ActualFast.17."])
AvgActualFastSess15[18]<-mean(mydata[mydata$Sess==15,"ActualFast.18."])
AvgActualFastSess15[19]<-mean(mydata[mydata$Sess==15,"ActualFast.19."])
AvgActualFastSess15[20]<-mean(mydata[mydata$Sess==15,"ActualFast.20."])
AvgActualFastSess15[21]<-mean(mydata[mydata$Sess==15,"ActualFast.21."])
AvgActualFastSess15[22]<-mean(mydata[mydata$Sess==15,"ActualFast.22."])
AvgActualFastSess15[23]<-mean(mydata[mydata$Sess==15,"ActualFast.23."])
AvgActualFastSess15[24]<-mean(mydata[mydata$Sess==15,"ActualFast.24."])
AvgActualFastSess15[25]<-mean(mydata[mydata$Sess==15,"ActualFast.25."])
AvgActualSlowSess15<-numeric(25)
AvgActualSlowSess15[1]<-mean(mydata[mydata$Sess==15,"ActualSlow.1."])
AvgActualSlowSess15[2]<-mean(mydata[mydata$Sess==15,"ActualSlow.2."])
AvgActualSlowSess15[3]<-mean(mydata[mydata$Sess==15,"ActualSlow.3."])
AvgActualSlowSess15[4]<-mean(mydata[mydata$Sess==15,"ActualSlow.4."])
AvgActualSlowSess15[5]<-mean(mydata[mydata$Sess==15,"ActualSlow.5."])
AvgActualSlowSess15[6]<-mean(mydata[mydata$Sess==15,"ActualSlow.6."])
AvgActualSlowSess15[7]<-mean(mydata[mydata$Sess==15,"ActualSlow.7."])
AvgActualSlowSess15[8]<-mean(mydata[mydata$Sess==15,"ActualSlow.8."])
AvgActualSlowSess15[9]<-mean(mydata[mydata$Sess==15,"ActualSlow.9."])
AvgActualSlowSess15[10]<-mean(mydata[mydata$Sess==15,"ActualSlow.10."])
AvgActualSlowSess15[11]<-mean(mydata[mydata$Sess==15,"ActualSlow.11."])
AvgActualSlowSess15[12]<-mean(mydata[mydata$Sess==15,"ActualSlow.12."])
AvgActualSlowSess15[13]<-mean(mydata[mydata$Sess==15,"ActualSlow.13."])
AvgActualSlowSess15[14]<-mean(mydata[mydata$Sess==15,"ActualSlow.14."])
AvgActualSlowSess15[15]<-mean(mydata[mydata$Sess==15,"ActualSlow.15."])
AvgActualSlowSess15[16]<-mean(mydata[mydata$Sess==15,"ActualSlow.16."])
AvgActualSlowSess15[17]<-mean(mydata[mydata$Sess==15,"ActualSlow.17."])
AvgActualSlowSess15[18]<-mean(mydata[mydata$Sess==15,"ActualSlow.18."])
AvgActualSlowSess15[19]<-mean(mydata[mydata$Sess==15,"ActualSlow.19."])
AvgActualSlowSess15[20]<-mean(mydata[mydata$Sess==15,"ActualSlow.20."])
AvgActualSlowSess15[21]<-mean(mydata[mydata$Sess==15,"ActualSlow.21."])
AvgActualSlowSess15[22]<-mean(mydata[mydata$Sess==15,"ActualSlow.22."])
AvgActualSlowSess15[23]<-mean(mydata[mydata$Sess==15,"ActualSlow.23."])
AvgActualSlowSess15[24]<-mean(mydata[mydata$Sess==15,"ActualSlow.24."])
AvgActualSlowSess15[25]<-mean(mydata[mydata$Sess==15,"ActualSlow.25."])
AvgActualAutoSess15<-numeric(25)
AvgActualAutoSess15[1]<-mean(mydata[mydata$Sess==15,"ActualAuto.1."])
AvgActualAutoSess15[2]<-mean(mydata[mydata$Sess==15,"ActualAuto.2."])
AvgActualAutoSess15[3]<-mean(mydata[mydata$Sess==15,"ActualAuto.3."])
AvgActualAutoSess15[4]<-mean(mydata[mydata$Sess==15,"ActualAuto.4."])
AvgActualAutoSess15[5]<-mean(mydata[mydata$Sess==15,"ActualAuto.5."])
AvgActualAutoSess15[6]<-mean(mydata[mydata$Sess==15,"ActualAuto.6."])
AvgActualAutoSess15[7]<-mean(mydata[mydata$Sess==15,"ActualAuto.7."])
AvgActualAutoSess15[8]<-mean(mydata[mydata$Sess==15,"ActualAuto.8."])
AvgActualAutoSess15[9]<-mean(mydata[mydata$Sess==15,"ActualAuto.9."])
AvgActualAutoSess15[10]<-mean(mydata[mydata$Sess==15,"ActualAuto.10."])
AvgActualAutoSess15[11]<-mean(mydata[mydata$Sess==15,"ActualAuto.11."])
AvgActualAutoSess15[12]<-mean(mydata[mydata$Sess==15,"ActualAuto.12."])
AvgActualAutoSess15[13]<-mean(mydata[mydata$Sess==15,"ActualAuto.13."])
AvgActualAutoSess15[14]<-mean(mydata[mydata$Sess==15,"ActualAuto.14."])
AvgActualAutoSess15[15]<-mean(mydata[mydata$Sess==15,"ActualAuto.15."])
AvgActualAutoSess15[16]<-mean(mydata[mydata$Sess==15,"ActualAuto.16."])
AvgActualAutoSess15[17]<-mean(mydata[mydata$Sess==15,"ActualAuto.17."])
AvgActualAutoSess15[18]<-mean(mydata[mydata$Sess==15,"ActualAuto.18."])
AvgActualAutoSess15[19]<-mean(mydata[mydata$Sess==15,"ActualAuto.19."])
AvgActualAutoSess15[20]<-mean(mydata[mydata$Sess==15,"ActualAuto.20."])
AvgActualAutoSess15[21]<-mean(mydata[mydata$Sess==15,"ActualAuto.21."])
AvgActualAutoSess15[22]<-mean(mydata[mydata$Sess==15,"ActualAuto.22."])
AvgActualAutoSess15[23]<-mean(mydata[mydata$Sess==15,"ActualAuto.23."])
AvgActualAutoSess15[24]<-mean(mydata[mydata$Sess==15,"ActualAuto.24."])
AvgActualAutoSess15[25]<-mean(mydata[mydata$Sess==15,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess15, AvgActualSlowSess15, AvgActualAutoSess15)
Sess15PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess15, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess15, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess15, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 15 (Control 6)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess15PlotActual

Auto <- jitter(AvgActualAutoSess15)
Slow <- jitter(AvgActualSlowSess15)
Fast <- jitter(AvgActualFastSess15)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess15TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess15TriActual


Auto <- jitter(AvgActualAutoSess15)
Slow <- jitter(AvgActualSlowSess15)
Fast <- jitter(AvgActualFastSess15)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess15Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 15 - Control 6') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess15Tri2Actual

#Plot for Session 16
AvgActualFastSess16<-numeric(25)
AvgActualFastSess16[1]<-mean(mydata[mydata$Sess==16,"ActualFast.1."])
AvgActualFastSess16[2]<-mean(mydata[mydata$Sess==16,"ActualFast.2."])
AvgActualFastSess16[3]<-mean(mydata[mydata$Sess==16,"ActualFast.3."])
AvgActualFastSess16[4]<-mean(mydata[mydata$Sess==16,"ActualFast.4."])
AvgActualFastSess16[5]<-mean(mydata[mydata$Sess==16,"ActualFast.5."])
AvgActualFastSess16[6]<-mean(mydata[mydata$Sess==16,"ActualFast.6."])
AvgActualFastSess16[7]<-mean(mydata[mydata$Sess==16,"ActualFast.7."])
AvgActualFastSess16[8]<-mean(mydata[mydata$Sess==16,"ActualFast.8."])
AvgActualFastSess16[9]<-mean(mydata[mydata$Sess==16,"ActualFast.9."])
AvgActualFastSess16[10]<-mean(mydata[mydata$Sess==16,"ActualFast.10."])
AvgActualFastSess16[11]<-mean(mydata[mydata$Sess==16,"ActualFast.11."])
AvgActualFastSess16[12]<-mean(mydata[mydata$Sess==16,"ActualFast.12."])
AvgActualFastSess16[13]<-mean(mydata[mydata$Sess==16,"ActualFast.13."])
AvgActualFastSess16[14]<-mean(mydata[mydata$Sess==16,"ActualFast.14."])
AvgActualFastSess16[15]<-mean(mydata[mydata$Sess==16,"ActualFast.15."])
AvgActualFastSess16[16]<-mean(mydata[mydata$Sess==16,"ActualFast.16."])
AvgActualFastSess16[17]<-mean(mydata[mydata$Sess==16,"ActualFast.17."])
AvgActualFastSess16[18]<-mean(mydata[mydata$Sess==16,"ActualFast.18."])
AvgActualFastSess16[19]<-mean(mydata[mydata$Sess==16,"ActualFast.19."])
AvgActualFastSess16[20]<-mean(mydata[mydata$Sess==16,"ActualFast.20."])
AvgActualFastSess16[21]<-mean(mydata[mydata$Sess==16,"ActualFast.21."])
AvgActualFastSess16[22]<-mean(mydata[mydata$Sess==16,"ActualFast.22."])
AvgActualFastSess16[23]<-mean(mydata[mydata$Sess==16,"ActualFast.23."])
AvgActualFastSess16[24]<-mean(mydata[mydata$Sess==16,"ActualFast.24."])
AvgActualFastSess16[25]<-mean(mydata[mydata$Sess==16,"ActualFast.25."])
AvgActualSlowSess16<-numeric(25)
AvgActualSlowSess16[1]<-mean(mydata[mydata$Sess==16,"ActualSlow.1."])
AvgActualSlowSess16[2]<-mean(mydata[mydata$Sess==16,"ActualSlow.2."])
AvgActualSlowSess16[3]<-mean(mydata[mydata$Sess==16,"ActualSlow.3."])
AvgActualSlowSess16[4]<-mean(mydata[mydata$Sess==16,"ActualSlow.4."])
AvgActualSlowSess16[5]<-mean(mydata[mydata$Sess==16,"ActualSlow.5."])
AvgActualSlowSess16[6]<-mean(mydata[mydata$Sess==16,"ActualSlow.6."])
AvgActualSlowSess16[7]<-mean(mydata[mydata$Sess==16,"ActualSlow.7."])
AvgActualSlowSess16[8]<-mean(mydata[mydata$Sess==16,"ActualSlow.8."])
AvgActualSlowSess16[9]<-mean(mydata[mydata$Sess==16,"ActualSlow.9."])
AvgActualSlowSess16[10]<-mean(mydata[mydata$Sess==16,"ActualSlow.10."])
AvgActualSlowSess16[11]<-mean(mydata[mydata$Sess==16,"ActualSlow.11."])
AvgActualSlowSess16[12]<-mean(mydata[mydata$Sess==16,"ActualSlow.12."])
AvgActualSlowSess16[13]<-mean(mydata[mydata$Sess==16,"ActualSlow.13."])
AvgActualSlowSess16[14]<-mean(mydata[mydata$Sess==16,"ActualSlow.14."])
AvgActualSlowSess16[15]<-mean(mydata[mydata$Sess==16,"ActualSlow.15."])
AvgActualSlowSess16[16]<-mean(mydata[mydata$Sess==16,"ActualSlow.16."])
AvgActualSlowSess16[17]<-mean(mydata[mydata$Sess==16,"ActualSlow.17."])
AvgActualSlowSess16[18]<-mean(mydata[mydata$Sess==16,"ActualSlow.18."])
AvgActualSlowSess16[19]<-mean(mydata[mydata$Sess==16,"ActualSlow.19."])
AvgActualSlowSess16[20]<-mean(mydata[mydata$Sess==16,"ActualSlow.20."])
AvgActualSlowSess16[21]<-mean(mydata[mydata$Sess==16,"ActualSlow.21."])
AvgActualSlowSess16[22]<-mean(mydata[mydata$Sess==16,"ActualSlow.22."])
AvgActualSlowSess16[23]<-mean(mydata[mydata$Sess==16,"ActualSlow.23."])
AvgActualSlowSess16[24]<-mean(mydata[mydata$Sess==16,"ActualSlow.24."])
AvgActualSlowSess16[25]<-mean(mydata[mydata$Sess==16,"ActualSlow.25."])
AvgActualAutoSess16<-numeric(25)
AvgActualAutoSess16[1]<-mean(mydata[mydata$Sess==16,"ActualAuto.1."])
AvgActualAutoSess16[2]<-mean(mydata[mydata$Sess==16,"ActualAuto.2."])
AvgActualAutoSess16[3]<-mean(mydata[mydata$Sess==16,"ActualAuto.3."])
AvgActualAutoSess16[4]<-mean(mydata[mydata$Sess==16,"ActualAuto.4."])
AvgActualAutoSess16[5]<-mean(mydata[mydata$Sess==16,"ActualAuto.5."])
AvgActualAutoSess16[6]<-mean(mydata[mydata$Sess==16,"ActualAuto.6."])
AvgActualAutoSess16[7]<-mean(mydata[mydata$Sess==16,"ActualAuto.7."])
AvgActualAutoSess16[8]<-mean(mydata[mydata$Sess==16,"ActualAuto.8."])
AvgActualAutoSess16[9]<-mean(mydata[mydata$Sess==16,"ActualAuto.9."])
AvgActualAutoSess16[10]<-mean(mydata[mydata$Sess==16,"ActualAuto.10."])
AvgActualAutoSess16[11]<-mean(mydata[mydata$Sess==16,"ActualAuto.11."])
AvgActualAutoSess16[12]<-mean(mydata[mydata$Sess==16,"ActualAuto.12."])
AvgActualAutoSess16[13]<-mean(mydata[mydata$Sess==16,"ActualAuto.13."])
AvgActualAutoSess16[14]<-mean(mydata[mydata$Sess==16,"ActualAuto.14."])
AvgActualAutoSess16[15]<-mean(mydata[mydata$Sess==16,"ActualAuto.15."])
AvgActualAutoSess16[16]<-mean(mydata[mydata$Sess==16,"ActualAuto.16."])
AvgActualAutoSess16[17]<-mean(mydata[mydata$Sess==16,"ActualAuto.17."])
AvgActualAutoSess16[18]<-mean(mydata[mydata$Sess==16,"ActualAuto.18."])
AvgActualAutoSess16[19]<-mean(mydata[mydata$Sess==16,"ActualAuto.19."])
AvgActualAutoSess16[20]<-mean(mydata[mydata$Sess==16,"ActualAuto.20."])
AvgActualAutoSess16[21]<-mean(mydata[mydata$Sess==16,"ActualAuto.21."])
AvgActualAutoSess16[22]<-mean(mydata[mydata$Sess==16,"ActualAuto.22."])
AvgActualAutoSess16[23]<-mean(mydata[mydata$Sess==16,"ActualAuto.23."])
AvgActualAutoSess16[24]<-mean(mydata[mydata$Sess==16,"ActualAuto.24."])
AvgActualAutoSess16[25]<-mean(mydata[mydata$Sess==16,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess16, AvgActualSlowSess16, AvgActualAutoSess16)
Sess16PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess16, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess16, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess16, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 16 (Fine 5)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess16PlotActual

Auto <- jitter(AvgActualAutoSess16)
Slow <- jitter(AvgActualSlowSess16)
Fast <- jitter(AvgActualFastSess16)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess16TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess16TriActual


Auto <- jitter(AvgActualAutoSess16)
Slow <- jitter(AvgActualSlowSess16)
Fast <- jitter(AvgActualFastSess16)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess16Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 16 - Fine 5') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess16Tri2Actual

#Plot for Session 17
AvgActualFastSess17<-numeric(25)
AvgActualFastSess17[1]<-mean(mydata[mydata$Sess==17,"ActualFast.1."])
AvgActualFastSess17[2]<-mean(mydata[mydata$Sess==17,"ActualFast.2."])
AvgActualFastSess17[3]<-mean(mydata[mydata$Sess==17,"ActualFast.3."])
AvgActualFastSess17[4]<-mean(mydata[mydata$Sess==17,"ActualFast.4."])
AvgActualFastSess17[5]<-mean(mydata[mydata$Sess==17,"ActualFast.5."])
AvgActualFastSess17[6]<-mean(mydata[mydata$Sess==17,"ActualFast.6."])
AvgActualFastSess17[7]<-mean(mydata[mydata$Sess==17,"ActualFast.7."])
AvgActualFastSess17[8]<-mean(mydata[mydata$Sess==17,"ActualFast.8."])
AvgActualFastSess17[9]<-mean(mydata[mydata$Sess==17,"ActualFast.9."])
AvgActualFastSess17[10]<-mean(mydata[mydata$Sess==17,"ActualFast.10."])
AvgActualFastSess17[11]<-mean(mydata[mydata$Sess==17,"ActualFast.11."])
AvgActualFastSess17[12]<-mean(mydata[mydata$Sess==17,"ActualFast.12."])
AvgActualFastSess17[13]<-mean(mydata[mydata$Sess==17,"ActualFast.13."])
AvgActualFastSess17[14]<-mean(mydata[mydata$Sess==17,"ActualFast.14."])
AvgActualFastSess17[15]<-mean(mydata[mydata$Sess==17,"ActualFast.15."])
AvgActualFastSess17[16]<-mean(mydata[mydata$Sess==17,"ActualFast.16."])
AvgActualFastSess17[17]<-mean(mydata[mydata$Sess==17,"ActualFast.17."])
AvgActualFastSess17[18]<-mean(mydata[mydata$Sess==17,"ActualFast.18."])
AvgActualFastSess17[19]<-mean(mydata[mydata$Sess==17,"ActualFast.19."])
AvgActualFastSess17[20]<-mean(mydata[mydata$Sess==17,"ActualFast.20."])
AvgActualFastSess17[21]<-mean(mydata[mydata$Sess==17,"ActualFast.21."])
AvgActualFastSess17[22]<-mean(mydata[mydata$Sess==17,"ActualFast.22."])
AvgActualFastSess17[23]<-mean(mydata[mydata$Sess==17,"ActualFast.23."])
AvgActualFastSess17[24]<-mean(mydata[mydata$Sess==17,"ActualFast.24."])
AvgActualFastSess17[25]<-mean(mydata[mydata$Sess==17,"ActualFast.25."])
AvgActualSlowSess17<-numeric(25)
AvgActualSlowSess17[1]<-mean(mydata[mydata$Sess==17,"ActualSlow.1."])
AvgActualSlowSess17[2]<-mean(mydata[mydata$Sess==17,"ActualSlow.2."])
AvgActualSlowSess17[3]<-mean(mydata[mydata$Sess==17,"ActualSlow.3."])
AvgActualSlowSess17[4]<-mean(mydata[mydata$Sess==17,"ActualSlow.4."])
AvgActualSlowSess17[5]<-mean(mydata[mydata$Sess==17,"ActualSlow.5."])
AvgActualSlowSess17[6]<-mean(mydata[mydata$Sess==17,"ActualSlow.6."])
AvgActualSlowSess17[7]<-mean(mydata[mydata$Sess==17,"ActualSlow.7."])
AvgActualSlowSess17[8]<-mean(mydata[mydata$Sess==17,"ActualSlow.8."])
AvgActualSlowSess17[9]<-mean(mydata[mydata$Sess==17,"ActualSlow.9."])
AvgActualSlowSess17[10]<-mean(mydata[mydata$Sess==17,"ActualSlow.10."])
AvgActualSlowSess17[11]<-mean(mydata[mydata$Sess==17,"ActualSlow.11."])
AvgActualSlowSess17[12]<-mean(mydata[mydata$Sess==17,"ActualSlow.12."])
AvgActualSlowSess17[13]<-mean(mydata[mydata$Sess==17,"ActualSlow.13."])
AvgActualSlowSess17[14]<-mean(mydata[mydata$Sess==17,"ActualSlow.14."])
AvgActualSlowSess17[15]<-mean(mydata[mydata$Sess==17,"ActualSlow.15."])
AvgActualSlowSess17[16]<-mean(mydata[mydata$Sess==17,"ActualSlow.16."])
AvgActualSlowSess17[17]<-mean(mydata[mydata$Sess==17,"ActualSlow.17."])
AvgActualSlowSess17[18]<-mean(mydata[mydata$Sess==17,"ActualSlow.18."])
AvgActualSlowSess17[19]<-mean(mydata[mydata$Sess==17,"ActualSlow.19."])
AvgActualSlowSess17[20]<-mean(mydata[mydata$Sess==17,"ActualSlow.20."])
AvgActualSlowSess17[21]<-mean(mydata[mydata$Sess==17,"ActualSlow.21."])
AvgActualSlowSess17[22]<-mean(mydata[mydata$Sess==17,"ActualSlow.22."])
AvgActualSlowSess17[23]<-mean(mydata[mydata$Sess==17,"ActualSlow.23."])
AvgActualSlowSess17[24]<-mean(mydata[mydata$Sess==17,"ActualSlow.24."])
AvgActualSlowSess17[25]<-mean(mydata[mydata$Sess==17,"ActualSlow.25."])
AvgActualAutoSess17<-numeric(25)
AvgActualAutoSess17[1]<-mean(mydata[mydata$Sess==17,"ActualAuto.1."])
AvgActualAutoSess17[2]<-mean(mydata[mydata$Sess==17,"ActualAuto.2."])
AvgActualAutoSess17[3]<-mean(mydata[mydata$Sess==17,"ActualAuto.3."])
AvgActualAutoSess17[4]<-mean(mydata[mydata$Sess==17,"ActualAuto.4."])
AvgActualAutoSess17[5]<-mean(mydata[mydata$Sess==17,"ActualAuto.5."])
AvgActualAutoSess17[6]<-mean(mydata[mydata$Sess==17,"ActualAuto.6."])
AvgActualAutoSess17[7]<-mean(mydata[mydata$Sess==17,"ActualAuto.7."])
AvgActualAutoSess17[8]<-mean(mydata[mydata$Sess==17,"ActualAuto.8."])
AvgActualAutoSess17[9]<-mean(mydata[mydata$Sess==17,"ActualAuto.9."])
AvgActualAutoSess17[10]<-mean(mydata[mydata$Sess==17,"ActualAuto.10."])
AvgActualAutoSess17[11]<-mean(mydata[mydata$Sess==17,"ActualAuto.11."])
AvgActualAutoSess17[12]<-mean(mydata[mydata$Sess==17,"ActualAuto.12."])
AvgActualAutoSess17[13]<-mean(mydata[mydata$Sess==17,"ActualAuto.13."])
AvgActualAutoSess17[14]<-mean(mydata[mydata$Sess==17,"ActualAuto.14."])
AvgActualAutoSess17[15]<-mean(mydata[mydata$Sess==17,"ActualAuto.15."])
AvgActualAutoSess17[16]<-mean(mydata[mydata$Sess==17,"ActualAuto.16."])
AvgActualAutoSess17[17]<-mean(mydata[mydata$Sess==17,"ActualAuto.17."])
AvgActualAutoSess17[18]<-mean(mydata[mydata$Sess==17,"ActualAuto.18."])
AvgActualAutoSess17[19]<-mean(mydata[mydata$Sess==17,"ActualAuto.19."])
AvgActualAutoSess17[20]<-mean(mydata[mydata$Sess==17,"ActualAuto.20."])
AvgActualAutoSess17[21]<-mean(mydata[mydata$Sess==17,"ActualAuto.21."])
AvgActualAutoSess17[22]<-mean(mydata[mydata$Sess==17,"ActualAuto.22."])
AvgActualAutoSess17[23]<-mean(mydata[mydata$Sess==17,"ActualAuto.23."])
AvgActualAutoSess17[24]<-mean(mydata[mydata$Sess==17,"ActualAuto.24."])
AvgActualAutoSess17[25]<-mean(mydata[mydata$Sess==17,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess17, AvgActualSlowSess17, AvgActualAutoSess17)
Sess17PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess17, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess17, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess17, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 17 (Association 6)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess17PlotActual

Auto <- jitter(AvgActualAutoSess17)
Slow <- jitter(AvgActualSlowSess17)
Fast <- jitter(AvgActualFastSess17)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess17TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess17TriActual


Auto <- jitter(AvgActualAutoSess17)
Slow <- jitter(AvgActualSlowSess17)
Fast <- jitter(AvgActualFastSess17)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess17Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 17 - Association 6') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess17Tri2Actual


#Plot for Session 18
AvgActualFastSess18<-numeric(25)
AvgActualFastSess18[1]<-mean(mydata[mydata$Sess==18,"ActualFast.1."])
AvgActualFastSess18[2]<-mean(mydata[mydata$Sess==18,"ActualFast.2."])
AvgActualFastSess18[3]<-mean(mydata[mydata$Sess==18,"ActualFast.3."])
AvgActualFastSess18[4]<-mean(mydata[mydata$Sess==18,"ActualFast.4."])
AvgActualFastSess18[5]<-mean(mydata[mydata$Sess==18,"ActualFast.5."])
AvgActualFastSess18[6]<-mean(mydata[mydata$Sess==18,"ActualFast.6."])
AvgActualFastSess18[7]<-mean(mydata[mydata$Sess==18,"ActualFast.7."])
AvgActualFastSess18[8]<-mean(mydata[mydata$Sess==18,"ActualFast.8."])
AvgActualFastSess18[9]<-mean(mydata[mydata$Sess==18,"ActualFast.9."])
AvgActualFastSess18[10]<-mean(mydata[mydata$Sess==18,"ActualFast.10."])
AvgActualFastSess18[11]<-mean(mydata[mydata$Sess==18,"ActualFast.11."])
AvgActualFastSess18[12]<-mean(mydata[mydata$Sess==18,"ActualFast.12."])
AvgActualFastSess18[13]<-mean(mydata[mydata$Sess==18,"ActualFast.13."])
AvgActualFastSess18[14]<-mean(mydata[mydata$Sess==18,"ActualFast.14."])
AvgActualFastSess18[15]<-mean(mydata[mydata$Sess==18,"ActualFast.15."])
AvgActualFastSess18[16]<-mean(mydata[mydata$Sess==18,"ActualFast.16."])
AvgActualFastSess18[17]<-mean(mydata[mydata$Sess==18,"ActualFast.17."])
AvgActualFastSess18[18]<-mean(mydata[mydata$Sess==18,"ActualFast.18."])
AvgActualFastSess18[19]<-mean(mydata[mydata$Sess==18,"ActualFast.19."])
AvgActualFastSess18[20]<-mean(mydata[mydata$Sess==18,"ActualFast.20."])
AvgActualFastSess18[21]<-mean(mydata[mydata$Sess==18,"ActualFast.21."])
AvgActualFastSess18[22]<-mean(mydata[mydata$Sess==18,"ActualFast.22."])
AvgActualFastSess18[23]<-mean(mydata[mydata$Sess==18,"ActualFast.23."])
AvgActualFastSess18[24]<-mean(mydata[mydata$Sess==18,"ActualFast.24."])
AvgActualFastSess18[25]<-mean(mydata[mydata$Sess==18,"ActualFast.25."])
AvgActualSlowSess18<-numeric(25)
AvgActualSlowSess18[1]<-mean(mydata[mydata$Sess==18,"ActualSlow.1."])
AvgActualSlowSess18[2]<-mean(mydata[mydata$Sess==18,"ActualSlow.2."])
AvgActualSlowSess18[3]<-mean(mydata[mydata$Sess==18,"ActualSlow.3."])
AvgActualSlowSess18[4]<-mean(mydata[mydata$Sess==18,"ActualSlow.4."])
AvgActualSlowSess18[5]<-mean(mydata[mydata$Sess==18,"ActualSlow.5."])
AvgActualSlowSess18[6]<-mean(mydata[mydata$Sess==18,"ActualSlow.6."])
AvgActualSlowSess18[7]<-mean(mydata[mydata$Sess==18,"ActualSlow.7."])
AvgActualSlowSess18[8]<-mean(mydata[mydata$Sess==18,"ActualSlow.8."])
AvgActualSlowSess18[9]<-mean(mydata[mydata$Sess==18,"ActualSlow.9."])
AvgActualSlowSess18[10]<-mean(mydata[mydata$Sess==18,"ActualSlow.10."])
AvgActualSlowSess18[11]<-mean(mydata[mydata$Sess==18,"ActualSlow.11."])
AvgActualSlowSess18[12]<-mean(mydata[mydata$Sess==18,"ActualSlow.12."])
AvgActualSlowSess18[13]<-mean(mydata[mydata$Sess==18,"ActualSlow.13."])
AvgActualSlowSess18[14]<-mean(mydata[mydata$Sess==18,"ActualSlow.14."])
AvgActualSlowSess18[15]<-mean(mydata[mydata$Sess==18,"ActualSlow.15."])
AvgActualSlowSess18[16]<-mean(mydata[mydata$Sess==18,"ActualSlow.16."])
AvgActualSlowSess18[17]<-mean(mydata[mydata$Sess==18,"ActualSlow.17."])
AvgActualSlowSess18[18]<-mean(mydata[mydata$Sess==18,"ActualSlow.18."])
AvgActualSlowSess18[19]<-mean(mydata[mydata$Sess==18,"ActualSlow.19."])
AvgActualSlowSess18[20]<-mean(mydata[mydata$Sess==18,"ActualSlow.20."])
AvgActualSlowSess18[21]<-mean(mydata[mydata$Sess==18,"ActualSlow.21."])
AvgActualSlowSess18[22]<-mean(mydata[mydata$Sess==18,"ActualSlow.22."])
AvgActualSlowSess18[23]<-mean(mydata[mydata$Sess==18,"ActualSlow.23."])
AvgActualSlowSess18[24]<-mean(mydata[mydata$Sess==18,"ActualSlow.24."])
AvgActualSlowSess18[25]<-mean(mydata[mydata$Sess==18,"ActualSlow.25."])
AvgActualAutoSess18<-numeric(25)
AvgActualAutoSess18[1]<-mean(mydata[mydata$Sess==18,"ActualAuto.1."])
AvgActualAutoSess18[2]<-mean(mydata[mydata$Sess==18,"ActualAuto.2."])
AvgActualAutoSess18[3]<-mean(mydata[mydata$Sess==18,"ActualAuto.3."])
AvgActualAutoSess18[4]<-mean(mydata[mydata$Sess==18,"ActualAuto.4."])
AvgActualAutoSess18[5]<-mean(mydata[mydata$Sess==18,"ActualAuto.5."])
AvgActualAutoSess18[6]<-mean(mydata[mydata$Sess==18,"ActualAuto.6."])
AvgActualAutoSess18[7]<-mean(mydata[mydata$Sess==18,"ActualAuto.7."])
AvgActualAutoSess18[8]<-mean(mydata[mydata$Sess==18,"ActualAuto.8."])
AvgActualAutoSess18[9]<-mean(mydata[mydata$Sess==18,"ActualAuto.9."])
AvgActualAutoSess18[10]<-mean(mydata[mydata$Sess==18,"ActualAuto.10."])
AvgActualAutoSess18[11]<-mean(mydata[mydata$Sess==18,"ActualAuto.11."])
AvgActualAutoSess18[12]<-mean(mydata[mydata$Sess==18,"ActualAuto.12."])
AvgActualAutoSess18[13]<-mean(mydata[mydata$Sess==18,"ActualAuto.13."])
AvgActualAutoSess18[14]<-mean(mydata[mydata$Sess==18,"ActualAuto.14."])
AvgActualAutoSess18[15]<-mean(mydata[mydata$Sess==18,"ActualAuto.15."])
AvgActualAutoSess18[16]<-mean(mydata[mydata$Sess==18,"ActualAuto.16."])
AvgActualAutoSess18[17]<-mean(mydata[mydata$Sess==18,"ActualAuto.17."])
AvgActualAutoSess18[18]<-mean(mydata[mydata$Sess==18,"ActualAuto.18."])
AvgActualAutoSess18[19]<-mean(mydata[mydata$Sess==18,"ActualAuto.19."])
AvgActualAutoSess18[20]<-mean(mydata[mydata$Sess==18,"ActualAuto.20."])
AvgActualAutoSess18[21]<-mean(mydata[mydata$Sess==18,"ActualAuto.21."])
AvgActualAutoSess18[22]<-mean(mydata[mydata$Sess==18,"ActualAuto.22."])
AvgActualAutoSess18[23]<-mean(mydata[mydata$Sess==18,"ActualAuto.23."])
AvgActualAutoSess18[24]<-mean(mydata[mydata$Sess==18,"ActualAuto.24."])
AvgActualAutoSess18[25]<-mean(mydata[mydata$Sess==18,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess18, AvgActualSlowSess18, AvgActualAutoSess18)
Sess18PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess18, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess18, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess18, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 18 (Fine 6)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess18PlotActual

Auto <- jitter(AvgActualAutoSess18)
Slow <- jitter(AvgActualSlowSess18)
Fast <- jitter(AvgActualFastSess18)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess18TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess18TriActual


Auto <- jitter(AvgActualAutoSess18)
Slow <- jitter(AvgActualSlowSess18)
Fast <- jitter(AvgActualFastSess18)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess18Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 18 - Fine 6') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess18Tri2Actual




#Plot for Session 19
AvgActualFastSess19<-numeric(25)
AvgActualFastSess19[1]<-mean(mydata[mydata$Sess==19,"ActualFast.1."])
AvgActualFastSess19[2]<-mean(mydata[mydata$Sess==19,"ActualFast.2."])
AvgActualFastSess19[3]<-mean(mydata[mydata$Sess==19,"ActualFast.3."])
AvgActualFastSess19[4]<-mean(mydata[mydata$Sess==19,"ActualFast.4."])
AvgActualFastSess19[5]<-mean(mydata[mydata$Sess==19,"ActualFast.5."])
AvgActualFastSess19[6]<-mean(mydata[mydata$Sess==19,"ActualFast.6."])
AvgActualFastSess19[7]<-mean(mydata[mydata$Sess==19,"ActualFast.7."])
AvgActualFastSess19[8]<-mean(mydata[mydata$Sess==19,"ActualFast.8."])
AvgActualFastSess19[9]<-mean(mydata[mydata$Sess==19,"ActualFast.9."])
AvgActualFastSess19[10]<-mean(mydata[mydata$Sess==19,"ActualFast.10."])
AvgActualFastSess19[11]<-mean(mydata[mydata$Sess==19,"ActualFast.11."])
AvgActualFastSess19[12]<-mean(mydata[mydata$Sess==19,"ActualFast.12."])
AvgActualFastSess19[13]<-mean(mydata[mydata$Sess==19,"ActualFast.13."])
AvgActualFastSess19[14]<-mean(mydata[mydata$Sess==19,"ActualFast.14."])
AvgActualFastSess19[15]<-mean(mydata[mydata$Sess==19,"ActualFast.15."])
AvgActualFastSess19[16]<-mean(mydata[mydata$Sess==19,"ActualFast.16."])
AvgActualFastSess19[17]<-mean(mydata[mydata$Sess==19,"ActualFast.17."])
AvgActualFastSess19[18]<-mean(mydata[mydata$Sess==19,"ActualFast.18."])
AvgActualFastSess19[19]<-mean(mydata[mydata$Sess==19,"ActualFast.19."])
AvgActualFastSess19[20]<-mean(mydata[mydata$Sess==19,"ActualFast.20."])
AvgActualFastSess19[21]<-mean(mydata[mydata$Sess==19,"ActualFast.21."])
AvgActualFastSess19[22]<-mean(mydata[mydata$Sess==19,"ActualFast.22."])
AvgActualFastSess19[23]<-mean(mydata[mydata$Sess==19,"ActualFast.23."])
AvgActualFastSess19[24]<-mean(mydata[mydata$Sess==19,"ActualFast.24."])
AvgActualFastSess19[25]<-mean(mydata[mydata$Sess==19,"ActualFast.25."])
AvgActualSlowSess19<-numeric(25)
AvgActualSlowSess19[1]<-mean(mydata[mydata$Sess==19,"ActualSlow.1."])
AvgActualSlowSess19[2]<-mean(mydata[mydata$Sess==19,"ActualSlow.2."])
AvgActualSlowSess19[3]<-mean(mydata[mydata$Sess==19,"ActualSlow.3."])
AvgActualSlowSess19[4]<-mean(mydata[mydata$Sess==19,"ActualSlow.4."])
AvgActualSlowSess19[5]<-mean(mydata[mydata$Sess==19,"ActualSlow.5."])
AvgActualSlowSess19[6]<-mean(mydata[mydata$Sess==19,"ActualSlow.6."])
AvgActualSlowSess19[7]<-mean(mydata[mydata$Sess==19,"ActualSlow.7."])
AvgActualSlowSess19[8]<-mean(mydata[mydata$Sess==19,"ActualSlow.8."])
AvgActualSlowSess19[9]<-mean(mydata[mydata$Sess==19,"ActualSlow.9."])
AvgActualSlowSess19[10]<-mean(mydata[mydata$Sess==19,"ActualSlow.10."])
AvgActualSlowSess19[11]<-mean(mydata[mydata$Sess==19,"ActualSlow.11."])
AvgActualSlowSess19[12]<-mean(mydata[mydata$Sess==19,"ActualSlow.12."])
AvgActualSlowSess19[13]<-mean(mydata[mydata$Sess==19,"ActualSlow.13."])
AvgActualSlowSess19[14]<-mean(mydata[mydata$Sess==19,"ActualSlow.14."])
AvgActualSlowSess19[15]<-mean(mydata[mydata$Sess==19,"ActualSlow.15."])
AvgActualSlowSess19[16]<-mean(mydata[mydata$Sess==19,"ActualSlow.16."])
AvgActualSlowSess19[17]<-mean(mydata[mydata$Sess==19,"ActualSlow.17."])
AvgActualSlowSess19[18]<-mean(mydata[mydata$Sess==19,"ActualSlow.18."])
AvgActualSlowSess19[19]<-mean(mydata[mydata$Sess==19,"ActualSlow.19."])
AvgActualSlowSess19[20]<-mean(mydata[mydata$Sess==19,"ActualSlow.20."])
AvgActualSlowSess19[21]<-mean(mydata[mydata$Sess==19,"ActualSlow.21."])
AvgActualSlowSess19[22]<-mean(mydata[mydata$Sess==19,"ActualSlow.22."])
AvgActualSlowSess19[23]<-mean(mydata[mydata$Sess==19,"ActualSlow.23."])
AvgActualSlowSess19[24]<-mean(mydata[mydata$Sess==19,"ActualSlow.24."])
AvgActualSlowSess19[25]<-mean(mydata[mydata$Sess==19,"ActualSlow.25."])
AvgActualAutoSess19<-numeric(25)
AvgActualAutoSess19[1]<-mean(mydata[mydata$Sess==19,"ActualAuto.1."])
AvgActualAutoSess19[2]<-mean(mydata[mydata$Sess==19,"ActualAuto.2."])
AvgActualAutoSess19[3]<-mean(mydata[mydata$Sess==19,"ActualAuto.3."])
AvgActualAutoSess19[4]<-mean(mydata[mydata$Sess==19,"ActualAuto.4."])
AvgActualAutoSess19[5]<-mean(mydata[mydata$Sess==19,"ActualAuto.5."])
AvgActualAutoSess19[6]<-mean(mydata[mydata$Sess==19,"ActualAuto.6."])
AvgActualAutoSess19[7]<-mean(mydata[mydata$Sess==19,"ActualAuto.7."])
AvgActualAutoSess19[8]<-mean(mydata[mydata$Sess==19,"ActualAuto.8."])
AvgActualAutoSess19[9]<-mean(mydata[mydata$Sess==19,"ActualAuto.9."])
AvgActualAutoSess19[10]<-mean(mydata[mydata$Sess==19,"ActualAuto.10."])
AvgActualAutoSess19[11]<-mean(mydata[mydata$Sess==19,"ActualAuto.11."])
AvgActualAutoSess19[12]<-mean(mydata[mydata$Sess==19,"ActualAuto.12."])
AvgActualAutoSess19[13]<-mean(mydata[mydata$Sess==19,"ActualAuto.13."])
AvgActualAutoSess19[14]<-mean(mydata[mydata$Sess==19,"ActualAuto.14."])
AvgActualAutoSess19[15]<-mean(mydata[mydata$Sess==19,"ActualAuto.15."])
AvgActualAutoSess19[16]<-mean(mydata[mydata$Sess==19,"ActualAuto.16."])
AvgActualAutoSess19[17]<-mean(mydata[mydata$Sess==19,"ActualAuto.17."])
AvgActualAutoSess19[18]<-mean(mydata[mydata$Sess==19,"ActualAuto.18."])
AvgActualAutoSess19[19]<-mean(mydata[mydata$Sess==19,"ActualAuto.19."])
AvgActualAutoSess19[20]<-mean(mydata[mydata$Sess==19,"ActualAuto.20."])
AvgActualAutoSess19[21]<-mean(mydata[mydata$Sess==19,"ActualAuto.21."])
AvgActualAutoSess19[22]<-mean(mydata[mydata$Sess==19,"ActualAuto.22."])
AvgActualAutoSess19[23]<-mean(mydata[mydata$Sess==19,"ActualAuto.23."])
AvgActualAutoSess19[24]<-mean(mydata[mydata$Sess==19,"ActualAuto.24."])
AvgActualAutoSess19[25]<-mean(mydata[mydata$Sess==19,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess19, AvgActualSlowSess19, AvgActualAutoSess19)
Sess19PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess19, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess19, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess19, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 19 (Association 7)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess19PlotActual

Auto <- jitter(AvgActualAutoSess19)
Slow <- jitter(AvgActualSlowSess19)
Fast <- jitter(AvgActualFastSess19)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess19TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess19TriActual


Auto <- jitter(AvgActualAutoSess19)
Slow <- jitter(AvgActualSlowSess19)
Fast <- jitter(AvgActualFastSess19)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess19Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 19 - Association 7') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess19Tri2Actual



#Plot for Session 20
AvgActualFastSess20<-numeric(25)
AvgActualFastSess20[1]<-mean(mydata[mydata$Sess==20,"ActualFast.1."])
AvgActualFastSess20[2]<-mean(mydata[mydata$Sess==20,"ActualFast.2."])
AvgActualFastSess20[3]<-mean(mydata[mydata$Sess==20,"ActualFast.3."])
AvgActualFastSess20[4]<-mean(mydata[mydata$Sess==20,"ActualFast.4."])
AvgActualFastSess20[5]<-mean(mydata[mydata$Sess==20,"ActualFast.5."])
AvgActualFastSess20[6]<-mean(mydata[mydata$Sess==20,"ActualFast.6."])
AvgActualFastSess20[7]<-mean(mydata[mydata$Sess==20,"ActualFast.7."])
AvgActualFastSess20[8]<-mean(mydata[mydata$Sess==20,"ActualFast.8."])
AvgActualFastSess20[9]<-mean(mydata[mydata$Sess==20,"ActualFast.9."])
AvgActualFastSess20[10]<-mean(mydata[mydata$Sess==20,"ActualFast.10."])
AvgActualFastSess20[11]<-mean(mydata[mydata$Sess==20,"ActualFast.11."])
AvgActualFastSess20[12]<-mean(mydata[mydata$Sess==20,"ActualFast.12."])
AvgActualFastSess20[13]<-mean(mydata[mydata$Sess==20,"ActualFast.13."])
AvgActualFastSess20[14]<-mean(mydata[mydata$Sess==20,"ActualFast.14."])
AvgActualFastSess20[15]<-mean(mydata[mydata$Sess==20,"ActualFast.15."])
AvgActualFastSess20[16]<-mean(mydata[mydata$Sess==20,"ActualFast.16."])
AvgActualFastSess20[17]<-mean(mydata[mydata$Sess==20,"ActualFast.17."])
AvgActualFastSess20[18]<-mean(mydata[mydata$Sess==20,"ActualFast.18."])
AvgActualFastSess20[19]<-mean(mydata[mydata$Sess==20,"ActualFast.19."])
AvgActualFastSess20[20]<-mean(mydata[mydata$Sess==20,"ActualFast.20."])
AvgActualFastSess20[21]<-mean(mydata[mydata$Sess==20,"ActualFast.21."])
AvgActualFastSess20[22]<-mean(mydata[mydata$Sess==20,"ActualFast.22."])
AvgActualFastSess20[23]<-mean(mydata[mydata$Sess==20,"ActualFast.23."])
AvgActualFastSess20[24]<-mean(mydata[mydata$Sess==20,"ActualFast.24."])
AvgActualFastSess20[25]<-mean(mydata[mydata$Sess==20,"ActualFast.25."])
AvgActualSlowSess20<-numeric(25)
AvgActualSlowSess20[1]<-mean(mydata[mydata$Sess==20,"ActualSlow.1."])
AvgActualSlowSess20[2]<-mean(mydata[mydata$Sess==20,"ActualSlow.2."])
AvgActualSlowSess20[3]<-mean(mydata[mydata$Sess==20,"ActualSlow.3."])
AvgActualSlowSess20[4]<-mean(mydata[mydata$Sess==20,"ActualSlow.4."])
AvgActualSlowSess20[5]<-mean(mydata[mydata$Sess==20,"ActualSlow.5."])
AvgActualSlowSess20[6]<-mean(mydata[mydata$Sess==20,"ActualSlow.6."])
AvgActualSlowSess20[7]<-mean(mydata[mydata$Sess==20,"ActualSlow.7."])
AvgActualSlowSess20[8]<-mean(mydata[mydata$Sess==20,"ActualSlow.8."])
AvgActualSlowSess20[9]<-mean(mydata[mydata$Sess==20,"ActualSlow.9."])
AvgActualSlowSess20[10]<-mean(mydata[mydata$Sess==20,"ActualSlow.10."])
AvgActualSlowSess20[11]<-mean(mydata[mydata$Sess==20,"ActualSlow.11."])
AvgActualSlowSess20[12]<-mean(mydata[mydata$Sess==20,"ActualSlow.12."])
AvgActualSlowSess20[13]<-mean(mydata[mydata$Sess==20,"ActualSlow.13."])
AvgActualSlowSess20[14]<-mean(mydata[mydata$Sess==20,"ActualSlow.14."])
AvgActualSlowSess20[15]<-mean(mydata[mydata$Sess==20,"ActualSlow.15."])
AvgActualSlowSess20[16]<-mean(mydata[mydata$Sess==20,"ActualSlow.16."])
AvgActualSlowSess20[17]<-mean(mydata[mydata$Sess==20,"ActualSlow.17."])
AvgActualSlowSess20[18]<-mean(mydata[mydata$Sess==20,"ActualSlow.18."])
AvgActualSlowSess20[19]<-mean(mydata[mydata$Sess==20,"ActualSlow.19."])
AvgActualSlowSess20[20]<-mean(mydata[mydata$Sess==20,"ActualSlow.20."])
AvgActualSlowSess20[21]<-mean(mydata[mydata$Sess==20,"ActualSlow.21."])
AvgActualSlowSess20[22]<-mean(mydata[mydata$Sess==20,"ActualSlow.22."])
AvgActualSlowSess20[23]<-mean(mydata[mydata$Sess==20,"ActualSlow.23."])
AvgActualSlowSess20[24]<-mean(mydata[mydata$Sess==20,"ActualSlow.24."])
AvgActualSlowSess20[25]<-mean(mydata[mydata$Sess==20,"ActualSlow.25."])
AvgActualAutoSess20<-numeric(25)
AvgActualAutoSess20[1]<-mean(mydata[mydata$Sess==20,"ActualAuto.1."])
AvgActualAutoSess20[2]<-mean(mydata[mydata$Sess==20,"ActualAuto.2."])
AvgActualAutoSess20[3]<-mean(mydata[mydata$Sess==20,"ActualAuto.3."])
AvgActualAutoSess20[4]<-mean(mydata[mydata$Sess==20,"ActualAuto.4."])
AvgActualAutoSess20[5]<-mean(mydata[mydata$Sess==20,"ActualAuto.5."])
AvgActualAutoSess20[6]<-mean(mydata[mydata$Sess==20,"ActualAuto.6."])
AvgActualAutoSess20[7]<-mean(mydata[mydata$Sess==20,"ActualAuto.7."])
AvgActualAutoSess20[8]<-mean(mydata[mydata$Sess==20,"ActualAuto.8."])
AvgActualAutoSess20[9]<-mean(mydata[mydata$Sess==20,"ActualAuto.9."])
AvgActualAutoSess20[10]<-mean(mydata[mydata$Sess==20,"ActualAuto.10."])
AvgActualAutoSess20[11]<-mean(mydata[mydata$Sess==20,"ActualAuto.11."])
AvgActualAutoSess20[12]<-mean(mydata[mydata$Sess==20,"ActualAuto.12."])
AvgActualAutoSess20[13]<-mean(mydata[mydata$Sess==20,"ActualAuto.13."])
AvgActualAutoSess20[14]<-mean(mydata[mydata$Sess==20,"ActualAuto.14."])
AvgActualAutoSess20[15]<-mean(mydata[mydata$Sess==20,"ActualAuto.15."])
AvgActualAutoSess20[16]<-mean(mydata[mydata$Sess==20,"ActualAuto.16."])
AvgActualAutoSess20[17]<-mean(mydata[mydata$Sess==20,"ActualAuto.17."])
AvgActualAutoSess20[18]<-mean(mydata[mydata$Sess==20,"ActualAuto.18."])
AvgActualAutoSess20[19]<-mean(mydata[mydata$Sess==20,"ActualAuto.19."])
AvgActualAutoSess20[20]<-mean(mydata[mydata$Sess==20,"ActualAuto.20."])
AvgActualAutoSess20[21]<-mean(mydata[mydata$Sess==20,"ActualAuto.21."])
AvgActualAutoSess20[22]<-mean(mydata[mydata$Sess==20,"ActualAuto.22."])
AvgActualAutoSess20[23]<-mean(mydata[mydata$Sess==20,"ActualAuto.23."])
AvgActualAutoSess20[24]<-mean(mydata[mydata$Sess==20,"ActualAuto.24."])
AvgActualAutoSess20[25]<-mean(mydata[mydata$Sess==20,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess20, AvgActualSlowSess20, AvgActualAutoSess20)
Sess20PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess20, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess20, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess20, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 20 (Control 7)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess20PlotActual

Auto <- jitter(AvgActualAutoSess20)
Slow <- jitter(AvgActualSlowSess20)
Fast <- jitter(AvgActualFastSess20)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess20TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess20TriActual


Auto <- jitter(AvgActualAutoSess20)
Slow <- jitter(AvgActualSlowSess20)
Fast <- jitter(AvgActualFastSess20)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess20Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 20 - Control 7') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess20Tri2Actual



#Plot for Session 21
AvgActualFastSess21<-numeric(25)
AvgActualFastSess21[1]<-mean(mydata[mydata$Sess==21,"ActualFast.1."])
AvgActualFastSess21[2]<-mean(mydata[mydata$Sess==21,"ActualFast.2."])
AvgActualFastSess21[3]<-mean(mydata[mydata$Sess==21,"ActualFast.3."])
AvgActualFastSess21[4]<-mean(mydata[mydata$Sess==21,"ActualFast.4."])
AvgActualFastSess21[5]<-mean(mydata[mydata$Sess==21,"ActualFast.5."])
AvgActualFastSess21[6]<-mean(mydata[mydata$Sess==21,"ActualFast.6."])
AvgActualFastSess21[7]<-mean(mydata[mydata$Sess==21,"ActualFast.7."])
AvgActualFastSess21[8]<-mean(mydata[mydata$Sess==21,"ActualFast.8."])
AvgActualFastSess21[9]<-mean(mydata[mydata$Sess==21,"ActualFast.9."])
AvgActualFastSess21[10]<-mean(mydata[mydata$Sess==21,"ActualFast.10."])
AvgActualFastSess21[11]<-mean(mydata[mydata$Sess==21,"ActualFast.11."])
AvgActualFastSess21[12]<-mean(mydata[mydata$Sess==21,"ActualFast.12."])
AvgActualFastSess21[13]<-mean(mydata[mydata$Sess==21,"ActualFast.13."])
AvgActualFastSess21[14]<-mean(mydata[mydata$Sess==21,"ActualFast.14."])
AvgActualFastSess21[15]<-mean(mydata[mydata$Sess==21,"ActualFast.15."])
AvgActualFastSess21[16]<-mean(mydata[mydata$Sess==21,"ActualFast.16."])
AvgActualFastSess21[17]<-mean(mydata[mydata$Sess==21,"ActualFast.17."])
AvgActualFastSess21[18]<-mean(mydata[mydata$Sess==21,"ActualFast.18."])
AvgActualFastSess21[19]<-mean(mydata[mydata$Sess==21,"ActualFast.19."])
AvgActualFastSess21[20]<-mean(mydata[mydata$Sess==21,"ActualFast.20."])
AvgActualFastSess21[21]<-mean(mydata[mydata$Sess==21,"ActualFast.21."])
AvgActualFastSess21[22]<-mean(mydata[mydata$Sess==21,"ActualFast.22."])
AvgActualFastSess21[23]<-mean(mydata[mydata$Sess==21,"ActualFast.23."])
AvgActualFastSess21[24]<-mean(mydata[mydata$Sess==21,"ActualFast.24."])
AvgActualFastSess21[25]<-mean(mydata[mydata$Sess==21,"ActualFast.25."])
AvgActualSlowSess21<-numeric(25)
AvgActualSlowSess21[1]<-mean(mydata[mydata$Sess==21,"ActualSlow.1."])
AvgActualSlowSess21[2]<-mean(mydata[mydata$Sess==21,"ActualSlow.2."])
AvgActualSlowSess21[3]<-mean(mydata[mydata$Sess==21,"ActualSlow.3."])
AvgActualSlowSess21[4]<-mean(mydata[mydata$Sess==21,"ActualSlow.4."])
AvgActualSlowSess21[5]<-mean(mydata[mydata$Sess==21,"ActualSlow.5."])
AvgActualSlowSess21[6]<-mean(mydata[mydata$Sess==21,"ActualSlow.6."])
AvgActualSlowSess21[7]<-mean(mydata[mydata$Sess==21,"ActualSlow.7."])
AvgActualSlowSess21[8]<-mean(mydata[mydata$Sess==21,"ActualSlow.8."])
AvgActualSlowSess21[9]<-mean(mydata[mydata$Sess==21,"ActualSlow.9."])
AvgActualSlowSess21[10]<-mean(mydata[mydata$Sess==21,"ActualSlow.10."])
AvgActualSlowSess21[11]<-mean(mydata[mydata$Sess==21,"ActualSlow.11."])
AvgActualSlowSess21[12]<-mean(mydata[mydata$Sess==21,"ActualSlow.12."])
AvgActualSlowSess21[13]<-mean(mydata[mydata$Sess==21,"ActualSlow.13."])
AvgActualSlowSess21[14]<-mean(mydata[mydata$Sess==21,"ActualSlow.14."])
AvgActualSlowSess21[15]<-mean(mydata[mydata$Sess==21,"ActualSlow.15."])
AvgActualSlowSess21[16]<-mean(mydata[mydata$Sess==21,"ActualSlow.16."])
AvgActualSlowSess21[17]<-mean(mydata[mydata$Sess==21,"ActualSlow.17."])
AvgActualSlowSess21[18]<-mean(mydata[mydata$Sess==21,"ActualSlow.18."])
AvgActualSlowSess21[19]<-mean(mydata[mydata$Sess==21,"ActualSlow.19."])
AvgActualSlowSess21[20]<-mean(mydata[mydata$Sess==21,"ActualSlow.20."])
AvgActualSlowSess21[21]<-mean(mydata[mydata$Sess==21,"ActualSlow.21."])
AvgActualSlowSess21[22]<-mean(mydata[mydata$Sess==21,"ActualSlow.22."])
AvgActualSlowSess21[23]<-mean(mydata[mydata$Sess==21,"ActualSlow.23."])
AvgActualSlowSess21[24]<-mean(mydata[mydata$Sess==21,"ActualSlow.24."])
AvgActualSlowSess21[25]<-mean(mydata[mydata$Sess==21,"ActualSlow.25."])
AvgActualAutoSess21<-numeric(25)
AvgActualAutoSess21[1]<-mean(mydata[mydata$Sess==21,"ActualAuto.1."])
AvgActualAutoSess21[2]<-mean(mydata[mydata$Sess==21,"ActualAuto.2."])
AvgActualAutoSess21[3]<-mean(mydata[mydata$Sess==21,"ActualAuto.3."])
AvgActualAutoSess21[4]<-mean(mydata[mydata$Sess==21,"ActualAuto.4."])
AvgActualAutoSess21[5]<-mean(mydata[mydata$Sess==21,"ActualAuto.5."])
AvgActualAutoSess21[6]<-mean(mydata[mydata$Sess==21,"ActualAuto.6."])
AvgActualAutoSess21[7]<-mean(mydata[mydata$Sess==21,"ActualAuto.7."])
AvgActualAutoSess21[8]<-mean(mydata[mydata$Sess==21,"ActualAuto.8."])
AvgActualAutoSess21[9]<-mean(mydata[mydata$Sess==21,"ActualAuto.9."])
AvgActualAutoSess21[10]<-mean(mydata[mydata$Sess==21,"ActualAuto.10."])
AvgActualAutoSess21[11]<-mean(mydata[mydata$Sess==21,"ActualAuto.11."])
AvgActualAutoSess21[12]<-mean(mydata[mydata$Sess==21,"ActualAuto.12."])
AvgActualAutoSess21[13]<-mean(mydata[mydata$Sess==21,"ActualAuto.13."])
AvgActualAutoSess21[14]<-mean(mydata[mydata$Sess==21,"ActualAuto.14."])
AvgActualAutoSess21[15]<-mean(mydata[mydata$Sess==21,"ActualAuto.15."])
AvgActualAutoSess21[16]<-mean(mydata[mydata$Sess==21,"ActualAuto.16."])
AvgActualAutoSess21[17]<-mean(mydata[mydata$Sess==21,"ActualAuto.17."])
AvgActualAutoSess21[18]<-mean(mydata[mydata$Sess==21,"ActualAuto.18."])
AvgActualAutoSess21[19]<-mean(mydata[mydata$Sess==21,"ActualAuto.19."])
AvgActualAutoSess21[20]<-mean(mydata[mydata$Sess==21,"ActualAuto.20."])
AvgActualAutoSess21[21]<-mean(mydata[mydata$Sess==21,"ActualAuto.21."])
AvgActualAutoSess21[22]<-mean(mydata[mydata$Sess==21,"ActualAuto.22."])
AvgActualAutoSess21[23]<-mean(mydata[mydata$Sess==21,"ActualAuto.23."])
AvgActualAutoSess21[24]<-mean(mydata[mydata$Sess==21,"ActualAuto.24."])
AvgActualAutoSess21[25]<-mean(mydata[mydata$Sess==21,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess21, AvgActualSlowSess21, AvgActualAutoSess21)
Sess21PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess21, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess21, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess21, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 21 (Association 8)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess21PlotActual

Auto <- jitter(AvgActualAutoSess21)
Slow <- jitter(AvgActualSlowSess21)
Fast <- jitter(AvgActualFastSess21)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess21TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess21TriActual


Auto <- jitter(AvgActualAutoSess21)
Slow <- jitter(AvgActualSlowSess21)
Fast <- jitter(AvgActualFastSess21)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess21Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 21 - Association 8') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess21Tri2Actual


#Plot for Session 22
AvgActualFastSess22<-numeric(25)
AvgActualFastSess22[1]<-mean(mydata[mydata$Sess==22,"ActualFast.1."])
AvgActualFastSess22[2]<-mean(mydata[mydata$Sess==22,"ActualFast.2."])
AvgActualFastSess22[3]<-mean(mydata[mydata$Sess==22,"ActualFast.3."])
AvgActualFastSess22[4]<-mean(mydata[mydata$Sess==22,"ActualFast.4."])
AvgActualFastSess22[5]<-mean(mydata[mydata$Sess==22,"ActualFast.5."])
AvgActualFastSess22[6]<-mean(mydata[mydata$Sess==22,"ActualFast.6."])
AvgActualFastSess22[7]<-mean(mydata[mydata$Sess==22,"ActualFast.7."])
AvgActualFastSess22[8]<-mean(mydata[mydata$Sess==22,"ActualFast.8."])
AvgActualFastSess22[9]<-mean(mydata[mydata$Sess==22,"ActualFast.9."])
AvgActualFastSess22[10]<-mean(mydata[mydata$Sess==22,"ActualFast.10."])
AvgActualFastSess22[11]<-mean(mydata[mydata$Sess==22,"ActualFast.11."])
AvgActualFastSess22[12]<-mean(mydata[mydata$Sess==22,"ActualFast.12."])
AvgActualFastSess22[13]<-mean(mydata[mydata$Sess==22,"ActualFast.13."])
AvgActualFastSess22[14]<-mean(mydata[mydata$Sess==22,"ActualFast.14."])
AvgActualFastSess22[15]<-mean(mydata[mydata$Sess==22,"ActualFast.15."])
AvgActualFastSess22[16]<-mean(mydata[mydata$Sess==22,"ActualFast.16."])
AvgActualFastSess22[17]<-mean(mydata[mydata$Sess==22,"ActualFast.17."])
AvgActualFastSess22[18]<-mean(mydata[mydata$Sess==22,"ActualFast.18."])
AvgActualFastSess22[19]<-mean(mydata[mydata$Sess==22,"ActualFast.19."])
AvgActualFastSess22[20]<-mean(mydata[mydata$Sess==22,"ActualFast.20."])
AvgActualFastSess22[21]<-mean(mydata[mydata$Sess==22,"ActualFast.21."])
AvgActualFastSess22[22]<-mean(mydata[mydata$Sess==22,"ActualFast.22."])
AvgActualFastSess22[23]<-mean(mydata[mydata$Sess==22,"ActualFast.23."])
AvgActualFastSess22[24]<-mean(mydata[mydata$Sess==22,"ActualFast.24."])
AvgActualFastSess22[25]<-mean(mydata[mydata$Sess==22,"ActualFast.25."])
AvgActualSlowSess22<-numeric(25)
AvgActualSlowSess22[1]<-mean(mydata[mydata$Sess==22,"ActualSlow.1."])
AvgActualSlowSess22[2]<-mean(mydata[mydata$Sess==22,"ActualSlow.2."])
AvgActualSlowSess22[3]<-mean(mydata[mydata$Sess==22,"ActualSlow.3."])
AvgActualSlowSess22[4]<-mean(mydata[mydata$Sess==22,"ActualSlow.4."])
AvgActualSlowSess22[5]<-mean(mydata[mydata$Sess==22,"ActualSlow.5."])
AvgActualSlowSess22[6]<-mean(mydata[mydata$Sess==22,"ActualSlow.6."])
AvgActualSlowSess22[7]<-mean(mydata[mydata$Sess==22,"ActualSlow.7."])
AvgActualSlowSess22[8]<-mean(mydata[mydata$Sess==22,"ActualSlow.8."])
AvgActualSlowSess22[9]<-mean(mydata[mydata$Sess==22,"ActualSlow.9."])
AvgActualSlowSess22[10]<-mean(mydata[mydata$Sess==22,"ActualSlow.10."])
AvgActualSlowSess22[11]<-mean(mydata[mydata$Sess==22,"ActualSlow.11."])
AvgActualSlowSess22[12]<-mean(mydata[mydata$Sess==22,"ActualSlow.12."])
AvgActualSlowSess22[13]<-mean(mydata[mydata$Sess==22,"ActualSlow.13."])
AvgActualSlowSess22[14]<-mean(mydata[mydata$Sess==22,"ActualSlow.14."])
AvgActualSlowSess22[15]<-mean(mydata[mydata$Sess==22,"ActualSlow.15."])
AvgActualSlowSess22[16]<-mean(mydata[mydata$Sess==22,"ActualSlow.16."])
AvgActualSlowSess22[17]<-mean(mydata[mydata$Sess==22,"ActualSlow.17."])
AvgActualSlowSess22[18]<-mean(mydata[mydata$Sess==22,"ActualSlow.18."])
AvgActualSlowSess22[19]<-mean(mydata[mydata$Sess==22,"ActualSlow.19."])
AvgActualSlowSess22[20]<-mean(mydata[mydata$Sess==22,"ActualSlow.20."])
AvgActualSlowSess22[21]<-mean(mydata[mydata$Sess==22,"ActualSlow.21."])
AvgActualSlowSess22[22]<-mean(mydata[mydata$Sess==22,"ActualSlow.22."])
AvgActualSlowSess22[23]<-mean(mydata[mydata$Sess==22,"ActualSlow.23."])
AvgActualSlowSess22[24]<-mean(mydata[mydata$Sess==22,"ActualSlow.24."])
AvgActualSlowSess22[25]<-mean(mydata[mydata$Sess==22,"ActualSlow.25."])
AvgActualAutoSess22<-numeric(25)
AvgActualAutoSess22[1]<-mean(mydata[mydata$Sess==22,"ActualAuto.1."])
AvgActualAutoSess22[2]<-mean(mydata[mydata$Sess==22,"ActualAuto.2."])
AvgActualAutoSess22[3]<-mean(mydata[mydata$Sess==22,"ActualAuto.3."])
AvgActualAutoSess22[4]<-mean(mydata[mydata$Sess==22,"ActualAuto.4."])
AvgActualAutoSess22[5]<-mean(mydata[mydata$Sess==22,"ActualAuto.5."])
AvgActualAutoSess22[6]<-mean(mydata[mydata$Sess==22,"ActualAuto.6."])
AvgActualAutoSess22[7]<-mean(mydata[mydata$Sess==22,"ActualAuto.7."])
AvgActualAutoSess22[8]<-mean(mydata[mydata$Sess==22,"ActualAuto.8."])
AvgActualAutoSess22[9]<-mean(mydata[mydata$Sess==22,"ActualAuto.9."])
AvgActualAutoSess22[10]<-mean(mydata[mydata$Sess==22,"ActualAuto.10."])
AvgActualAutoSess22[11]<-mean(mydata[mydata$Sess==22,"ActualAuto.11."])
AvgActualAutoSess22[12]<-mean(mydata[mydata$Sess==22,"ActualAuto.12."])
AvgActualAutoSess22[13]<-mean(mydata[mydata$Sess==22,"ActualAuto.13."])
AvgActualAutoSess22[14]<-mean(mydata[mydata$Sess==22,"ActualAuto.14."])
AvgActualAutoSess22[15]<-mean(mydata[mydata$Sess==22,"ActualAuto.15."])
AvgActualAutoSess22[16]<-mean(mydata[mydata$Sess==22,"ActualAuto.16."])
AvgActualAutoSess22[17]<-mean(mydata[mydata$Sess==22,"ActualAuto.17."])
AvgActualAutoSess22[18]<-mean(mydata[mydata$Sess==22,"ActualAuto.18."])
AvgActualAutoSess22[19]<-mean(mydata[mydata$Sess==22,"ActualAuto.19."])
AvgActualAutoSess22[20]<-mean(mydata[mydata$Sess==22,"ActualAuto.20."])
AvgActualAutoSess22[21]<-mean(mydata[mydata$Sess==22,"ActualAuto.21."])
AvgActualAutoSess22[22]<-mean(mydata[mydata$Sess==22,"ActualAuto.22."])
AvgActualAutoSess22[23]<-mean(mydata[mydata$Sess==22,"ActualAuto.23."])
AvgActualAutoSess22[24]<-mean(mydata[mydata$Sess==22,"ActualAuto.24."])
AvgActualAutoSess22[25]<-mean(mydata[mydata$Sess==22,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess22, AvgActualSlowSess22, AvgActualAutoSess22)
Sess22PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess22, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess22, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess22, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 22 (Fine 7)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess22PlotActual

Auto <- jitter(AvgActualAutoSess22)
Slow <- jitter(AvgActualSlowSess22)
Fast <- jitter(AvgActualFastSess22)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess22TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess22TriActual


Auto <- jitter(AvgActualAutoSess22)
Slow <- jitter(AvgActualSlowSess22)
Fast <- jitter(AvgActualFastSess22)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess22Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 22 - Fine 7') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess22Tri2Actual


#Plot for Session 23
AvgActualFastSess23<-numeric(25)
AvgActualFastSess23[1]<-mean(mydata[mydata$Sess==23,"ActualFast.1."])
AvgActualFastSess23[2]<-mean(mydata[mydata$Sess==23,"ActualFast.2."])
AvgActualFastSess23[3]<-mean(mydata[mydata$Sess==23,"ActualFast.3."])
AvgActualFastSess23[4]<-mean(mydata[mydata$Sess==23,"ActualFast.4."])
AvgActualFastSess23[5]<-mean(mydata[mydata$Sess==23,"ActualFast.5."])
AvgActualFastSess23[6]<-mean(mydata[mydata$Sess==23,"ActualFast.6."])
AvgActualFastSess23[7]<-mean(mydata[mydata$Sess==23,"ActualFast.7."])
AvgActualFastSess23[8]<-mean(mydata[mydata$Sess==23,"ActualFast.8."])
AvgActualFastSess23[9]<-mean(mydata[mydata$Sess==23,"ActualFast.9."])
AvgActualFastSess23[10]<-mean(mydata[mydata$Sess==23,"ActualFast.10."])
AvgActualFastSess23[11]<-mean(mydata[mydata$Sess==23,"ActualFast.11."])
AvgActualFastSess23[12]<-mean(mydata[mydata$Sess==23,"ActualFast.12."])
AvgActualFastSess23[13]<-mean(mydata[mydata$Sess==23,"ActualFast.13."])
AvgActualFastSess23[14]<-mean(mydata[mydata$Sess==23,"ActualFast.14."])
AvgActualFastSess23[15]<-mean(mydata[mydata$Sess==23,"ActualFast.15."])
AvgActualFastSess23[16]<-mean(mydata[mydata$Sess==23,"ActualFast.16."])
AvgActualFastSess23[17]<-mean(mydata[mydata$Sess==23,"ActualFast.17."])
AvgActualFastSess23[18]<-mean(mydata[mydata$Sess==23,"ActualFast.18."])
AvgActualFastSess23[19]<-mean(mydata[mydata$Sess==23,"ActualFast.19."])
AvgActualFastSess23[20]<-mean(mydata[mydata$Sess==23,"ActualFast.20."])
AvgActualFastSess23[21]<-mean(mydata[mydata$Sess==23,"ActualFast.21."])
AvgActualFastSess23[22]<-mean(mydata[mydata$Sess==23,"ActualFast.22."])
AvgActualFastSess23[23]<-mean(mydata[mydata$Sess==23,"ActualFast.23."])
AvgActualFastSess23[24]<-mean(mydata[mydata$Sess==23,"ActualFast.24."])
AvgActualFastSess23[25]<-mean(mydata[mydata$Sess==23,"ActualFast.25."])
AvgActualSlowSess23<-numeric(25)
AvgActualSlowSess23[1]<-mean(mydata[mydata$Sess==23,"ActualSlow.1."])
AvgActualSlowSess23[2]<-mean(mydata[mydata$Sess==23,"ActualSlow.2."])
AvgActualSlowSess23[3]<-mean(mydata[mydata$Sess==23,"ActualSlow.3."])
AvgActualSlowSess23[4]<-mean(mydata[mydata$Sess==23,"ActualSlow.4."])
AvgActualSlowSess23[5]<-mean(mydata[mydata$Sess==23,"ActualSlow.5."])
AvgActualSlowSess23[6]<-mean(mydata[mydata$Sess==23,"ActualSlow.6."])
AvgActualSlowSess23[7]<-mean(mydata[mydata$Sess==23,"ActualSlow.7."])
AvgActualSlowSess23[8]<-mean(mydata[mydata$Sess==23,"ActualSlow.8."])
AvgActualSlowSess23[9]<-mean(mydata[mydata$Sess==23,"ActualSlow.9."])
AvgActualSlowSess23[10]<-mean(mydata[mydata$Sess==23,"ActualSlow.10."])
AvgActualSlowSess23[11]<-mean(mydata[mydata$Sess==23,"ActualSlow.11."])
AvgActualSlowSess23[12]<-mean(mydata[mydata$Sess==23,"ActualSlow.12."])
AvgActualSlowSess23[13]<-mean(mydata[mydata$Sess==23,"ActualSlow.13."])
AvgActualSlowSess23[14]<-mean(mydata[mydata$Sess==23,"ActualSlow.14."])
AvgActualSlowSess23[15]<-mean(mydata[mydata$Sess==23,"ActualSlow.15."])
AvgActualSlowSess23[16]<-mean(mydata[mydata$Sess==23,"ActualSlow.16."])
AvgActualSlowSess23[17]<-mean(mydata[mydata$Sess==23,"ActualSlow.17."])
AvgActualSlowSess23[18]<-mean(mydata[mydata$Sess==23,"ActualSlow.18."])
AvgActualSlowSess23[19]<-mean(mydata[mydata$Sess==23,"ActualSlow.19."])
AvgActualSlowSess23[20]<-mean(mydata[mydata$Sess==23,"ActualSlow.20."])
AvgActualSlowSess23[21]<-mean(mydata[mydata$Sess==23,"ActualSlow.21."])
AvgActualSlowSess23[22]<-mean(mydata[mydata$Sess==23,"ActualSlow.22."])
AvgActualSlowSess23[23]<-mean(mydata[mydata$Sess==23,"ActualSlow.23."])
AvgActualSlowSess23[24]<-mean(mydata[mydata$Sess==23,"ActualSlow.24."])
AvgActualSlowSess23[25]<-mean(mydata[mydata$Sess==23,"ActualSlow.25."])
AvgActualAutoSess23<-numeric(25)
AvgActualAutoSess23[1]<-mean(mydata[mydata$Sess==23,"ActualAuto.1."])
AvgActualAutoSess23[2]<-mean(mydata[mydata$Sess==23,"ActualAuto.2."])
AvgActualAutoSess23[3]<-mean(mydata[mydata$Sess==23,"ActualAuto.3."])
AvgActualAutoSess23[4]<-mean(mydata[mydata$Sess==23,"ActualAuto.4."])
AvgActualAutoSess23[5]<-mean(mydata[mydata$Sess==23,"ActualAuto.5."])
AvgActualAutoSess23[6]<-mean(mydata[mydata$Sess==23,"ActualAuto.6."])
AvgActualAutoSess23[7]<-mean(mydata[mydata$Sess==23,"ActualAuto.7."])
AvgActualAutoSess23[8]<-mean(mydata[mydata$Sess==23,"ActualAuto.8."])
AvgActualAutoSess23[9]<-mean(mydata[mydata$Sess==23,"ActualAuto.9."])
AvgActualAutoSess23[10]<-mean(mydata[mydata$Sess==23,"ActualAuto.10."])
AvgActualAutoSess23[11]<-mean(mydata[mydata$Sess==23,"ActualAuto.11."])
AvgActualAutoSess23[12]<-mean(mydata[mydata$Sess==23,"ActualAuto.12."])
AvgActualAutoSess23[13]<-mean(mydata[mydata$Sess==23,"ActualAuto.13."])
AvgActualAutoSess23[14]<-mean(mydata[mydata$Sess==23,"ActualAuto.14."])
AvgActualAutoSess23[15]<-mean(mydata[mydata$Sess==23,"ActualAuto.15."])
AvgActualAutoSess23[16]<-mean(mydata[mydata$Sess==23,"ActualAuto.16."])
AvgActualAutoSess23[17]<-mean(mydata[mydata$Sess==23,"ActualAuto.17."])
AvgActualAutoSess23[18]<-mean(mydata[mydata$Sess==23,"ActualAuto.18."])
AvgActualAutoSess23[19]<-mean(mydata[mydata$Sess==23,"ActualAuto.19."])
AvgActualAutoSess23[20]<-mean(mydata[mydata$Sess==23,"ActualAuto.20."])
AvgActualAutoSess23[21]<-mean(mydata[mydata$Sess==23,"ActualAuto.21."])
AvgActualAutoSess23[22]<-mean(mydata[mydata$Sess==23,"ActualAuto.22."])
AvgActualAutoSess23[23]<-mean(mydata[mydata$Sess==23,"ActualAuto.23."])
AvgActualAutoSess23[24]<-mean(mydata[mydata$Sess==23,"ActualAuto.24."])
AvgActualAutoSess23[25]<-mean(mydata[mydata$Sess==23,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess23, AvgActualSlowSess23, AvgActualAutoSess23)
Sess23PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess23, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess23, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess23, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 23 (Punishment 1)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess23PlotActual

Auto <- jitter(AvgActualAutoSess23)
Slow <- jitter(AvgActualSlowSess23)
Fast <- jitter(AvgActualFastSess23)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess23TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess23TriActual


Auto <- jitter(AvgActualAutoSess23)
Slow <- jitter(AvgActualSlowSess23)
Fast <- jitter(AvgActualFastSess23)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess23Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 23 - Punishment 1') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess23Tri2Actual


#Plot for Session 24
AvgActualFastSess24<-numeric(25)
AvgActualFastSess24[1]<-mean(mydata[mydata$Sess==24,"ActualFast.1."])
AvgActualFastSess24[2]<-mean(mydata[mydata$Sess==24,"ActualFast.2."])
AvgActualFastSess24[3]<-mean(mydata[mydata$Sess==24,"ActualFast.3."])
AvgActualFastSess24[4]<-mean(mydata[mydata$Sess==24,"ActualFast.4."])
AvgActualFastSess24[5]<-mean(mydata[mydata$Sess==24,"ActualFast.5."])
AvgActualFastSess24[6]<-mean(mydata[mydata$Sess==24,"ActualFast.6."])
AvgActualFastSess24[7]<-mean(mydata[mydata$Sess==24,"ActualFast.7."])
AvgActualFastSess24[8]<-mean(mydata[mydata$Sess==24,"ActualFast.8."])
AvgActualFastSess24[9]<-mean(mydata[mydata$Sess==24,"ActualFast.9."])
AvgActualFastSess24[10]<-mean(mydata[mydata$Sess==24,"ActualFast.10."])
AvgActualFastSess24[11]<-mean(mydata[mydata$Sess==24,"ActualFast.11."])
AvgActualFastSess24[12]<-mean(mydata[mydata$Sess==24,"ActualFast.12."])
AvgActualFastSess24[13]<-mean(mydata[mydata$Sess==24,"ActualFast.13."])
AvgActualFastSess24[14]<-mean(mydata[mydata$Sess==24,"ActualFast.14."])
AvgActualFastSess24[15]<-mean(mydata[mydata$Sess==24,"ActualFast.15."])
AvgActualFastSess24[16]<-mean(mydata[mydata$Sess==24,"ActualFast.16."])
AvgActualFastSess24[17]<-mean(mydata[mydata$Sess==24,"ActualFast.17."])
AvgActualFastSess24[18]<-mean(mydata[mydata$Sess==24,"ActualFast.18."])
AvgActualFastSess24[19]<-mean(mydata[mydata$Sess==24,"ActualFast.19."])
AvgActualFastSess24[20]<-mean(mydata[mydata$Sess==24,"ActualFast.20."])
AvgActualFastSess24[21]<-mean(mydata[mydata$Sess==24,"ActualFast.21."])
AvgActualFastSess24[22]<-mean(mydata[mydata$Sess==24,"ActualFast.22."])
AvgActualFastSess24[23]<-mean(mydata[mydata$Sess==24,"ActualFast.23."])
AvgActualFastSess24[24]<-mean(mydata[mydata$Sess==24,"ActualFast.24."])
AvgActualFastSess24[25]<-mean(mydata[mydata$Sess==24,"ActualFast.25."])
AvgActualSlowSess24<-numeric(25)
AvgActualSlowSess24[1]<-mean(mydata[mydata$Sess==24,"ActualSlow.1."])
AvgActualSlowSess24[2]<-mean(mydata[mydata$Sess==24,"ActualSlow.2."])
AvgActualSlowSess24[3]<-mean(mydata[mydata$Sess==24,"ActualSlow.3."])
AvgActualSlowSess24[4]<-mean(mydata[mydata$Sess==24,"ActualSlow.4."])
AvgActualSlowSess24[5]<-mean(mydata[mydata$Sess==24,"ActualSlow.5."])
AvgActualSlowSess24[6]<-mean(mydata[mydata$Sess==24,"ActualSlow.6."])
AvgActualSlowSess24[7]<-mean(mydata[mydata$Sess==24,"ActualSlow.7."])
AvgActualSlowSess24[8]<-mean(mydata[mydata$Sess==24,"ActualSlow.8."])
AvgActualSlowSess24[9]<-mean(mydata[mydata$Sess==24,"ActualSlow.9."])
AvgActualSlowSess24[10]<-mean(mydata[mydata$Sess==24,"ActualSlow.10."])
AvgActualSlowSess24[11]<-mean(mydata[mydata$Sess==24,"ActualSlow.11."])
AvgActualSlowSess24[12]<-mean(mydata[mydata$Sess==24,"ActualSlow.12."])
AvgActualSlowSess24[13]<-mean(mydata[mydata$Sess==24,"ActualSlow.13."])
AvgActualSlowSess24[14]<-mean(mydata[mydata$Sess==24,"ActualSlow.14."])
AvgActualSlowSess24[15]<-mean(mydata[mydata$Sess==24,"ActualSlow.15."])
AvgActualSlowSess24[16]<-mean(mydata[mydata$Sess==24,"ActualSlow.16."])
AvgActualSlowSess24[17]<-mean(mydata[mydata$Sess==24,"ActualSlow.17."])
AvgActualSlowSess24[18]<-mean(mydata[mydata$Sess==24,"ActualSlow.18."])
AvgActualSlowSess24[19]<-mean(mydata[mydata$Sess==24,"ActualSlow.19."])
AvgActualSlowSess24[20]<-mean(mydata[mydata$Sess==24,"ActualSlow.20."])
AvgActualSlowSess24[21]<-mean(mydata[mydata$Sess==24,"ActualSlow.21."])
AvgActualSlowSess24[22]<-mean(mydata[mydata$Sess==24,"ActualSlow.22."])
AvgActualSlowSess24[23]<-mean(mydata[mydata$Sess==24,"ActualSlow.23."])
AvgActualSlowSess24[24]<-mean(mydata[mydata$Sess==24,"ActualSlow.24."])
AvgActualSlowSess24[25]<-mean(mydata[mydata$Sess==24,"ActualSlow.25."])
AvgActualAutoSess24<-numeric(25)
AvgActualAutoSess24[1]<-mean(mydata[mydata$Sess==24,"ActualAuto.1."])
AvgActualAutoSess24[2]<-mean(mydata[mydata$Sess==24,"ActualAuto.2."])
AvgActualAutoSess24[3]<-mean(mydata[mydata$Sess==24,"ActualAuto.3."])
AvgActualAutoSess24[4]<-mean(mydata[mydata$Sess==24,"ActualAuto.4."])
AvgActualAutoSess24[5]<-mean(mydata[mydata$Sess==24,"ActualAuto.5."])
AvgActualAutoSess24[6]<-mean(mydata[mydata$Sess==24,"ActualAuto.6."])
AvgActualAutoSess24[7]<-mean(mydata[mydata$Sess==24,"ActualAuto.7."])
AvgActualAutoSess24[8]<-mean(mydata[mydata$Sess==24,"ActualAuto.8."])
AvgActualAutoSess24[9]<-mean(mydata[mydata$Sess==24,"ActualAuto.9."])
AvgActualAutoSess24[10]<-mean(mydata[mydata$Sess==24,"ActualAuto.10."])
AvgActualAutoSess24[11]<-mean(mydata[mydata$Sess==24,"ActualAuto.11."])
AvgActualAutoSess24[12]<-mean(mydata[mydata$Sess==24,"ActualAuto.12."])
AvgActualAutoSess24[13]<-mean(mydata[mydata$Sess==24,"ActualAuto.13."])
AvgActualAutoSess24[14]<-mean(mydata[mydata$Sess==24,"ActualAuto.14."])
AvgActualAutoSess24[15]<-mean(mydata[mydata$Sess==24,"ActualAuto.15."])
AvgActualAutoSess24[16]<-mean(mydata[mydata$Sess==24,"ActualAuto.16."])
AvgActualAutoSess24[17]<-mean(mydata[mydata$Sess==24,"ActualAuto.17."])
AvgActualAutoSess24[18]<-mean(mydata[mydata$Sess==24,"ActualAuto.18."])
AvgActualAutoSess24[19]<-mean(mydata[mydata$Sess==24,"ActualAuto.19."])
AvgActualAutoSess24[20]<-mean(mydata[mydata$Sess==24,"ActualAuto.20."])
AvgActualAutoSess24[21]<-mean(mydata[mydata$Sess==24,"ActualAuto.21."])
AvgActualAutoSess24[22]<-mean(mydata[mydata$Sess==24,"ActualAuto.22."])
AvgActualAutoSess24[23]<-mean(mydata[mydata$Sess==24,"ActualAuto.23."])
AvgActualAutoSess24[24]<-mean(mydata[mydata$Sess==24,"ActualAuto.24."])
AvgActualAutoSess24[25]<-mean(mydata[mydata$Sess==24,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess24, AvgActualSlowSess24, AvgActualAutoSess24)
Sess24PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess24, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess24, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess24, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 24 (Fine 8)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess24PlotActual

Auto <- jitter(AvgActualAutoSess24)
Slow <- jitter(AvgActualSlowSess24)
Fast <- jitter(AvgActualFastSess24)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess24TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess24TriActual


Auto <- jitter(AvgActualAutoSess24)
Slow <- jitter(AvgActualSlowSess24)
Fast <- jitter(AvgActualFastSess24)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess24Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 24 - Fine 8') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess24Tri2Actual


#Plot for Session 25
AvgActualFastSess25<-numeric(25)
AvgActualFastSess25[1]<-mean(mydata[mydata$Sess==25,"ActualFast.1."])
AvgActualFastSess25[2]<-mean(mydata[mydata$Sess==25,"ActualFast.2."])
AvgActualFastSess25[3]<-mean(mydata[mydata$Sess==25,"ActualFast.3."])
AvgActualFastSess25[4]<-mean(mydata[mydata$Sess==25,"ActualFast.4."])
AvgActualFastSess25[5]<-mean(mydata[mydata$Sess==25,"ActualFast.5."])
AvgActualFastSess25[6]<-mean(mydata[mydata$Sess==25,"ActualFast.6."])
AvgActualFastSess25[7]<-mean(mydata[mydata$Sess==25,"ActualFast.7."])
AvgActualFastSess25[8]<-mean(mydata[mydata$Sess==25,"ActualFast.8."])
AvgActualFastSess25[9]<-mean(mydata[mydata$Sess==25,"ActualFast.9."])
AvgActualFastSess25[10]<-mean(mydata[mydata$Sess==25,"ActualFast.10."])
AvgActualFastSess25[11]<-mean(mydata[mydata$Sess==25,"ActualFast.11."])
AvgActualFastSess25[12]<-mean(mydata[mydata$Sess==25,"ActualFast.12."])
AvgActualFastSess25[13]<-mean(mydata[mydata$Sess==25,"ActualFast.13."])
AvgActualFastSess25[14]<-mean(mydata[mydata$Sess==25,"ActualFast.14."])
AvgActualFastSess25[15]<-mean(mydata[mydata$Sess==25,"ActualFast.15."])
AvgActualFastSess25[16]<-mean(mydata[mydata$Sess==25,"ActualFast.16."])
AvgActualFastSess25[17]<-mean(mydata[mydata$Sess==25,"ActualFast.17."])
AvgActualFastSess25[18]<-mean(mydata[mydata$Sess==25,"ActualFast.18."])
AvgActualFastSess25[19]<-mean(mydata[mydata$Sess==25,"ActualFast.19."])
AvgActualFastSess25[20]<-mean(mydata[mydata$Sess==25,"ActualFast.20."])
AvgActualFastSess25[21]<-mean(mydata[mydata$Sess==25,"ActualFast.21."])
AvgActualFastSess25[22]<-mean(mydata[mydata$Sess==25,"ActualFast.22."])
AvgActualFastSess25[23]<-mean(mydata[mydata$Sess==25,"ActualFast.23."])
AvgActualFastSess25[24]<-mean(mydata[mydata$Sess==25,"ActualFast.24."])
AvgActualFastSess25[25]<-mean(mydata[mydata$Sess==25,"ActualFast.25."])
AvgActualSlowSess25<-numeric(25)
AvgActualSlowSess25[1]<-mean(mydata[mydata$Sess==25,"ActualSlow.1."])
AvgActualSlowSess25[2]<-mean(mydata[mydata$Sess==25,"ActualSlow.2."])
AvgActualSlowSess25[3]<-mean(mydata[mydata$Sess==25,"ActualSlow.3."])
AvgActualSlowSess25[4]<-mean(mydata[mydata$Sess==25,"ActualSlow.4."])
AvgActualSlowSess25[5]<-mean(mydata[mydata$Sess==25,"ActualSlow.5."])
AvgActualSlowSess25[6]<-mean(mydata[mydata$Sess==25,"ActualSlow.6."])
AvgActualSlowSess25[7]<-mean(mydata[mydata$Sess==25,"ActualSlow.7."])
AvgActualSlowSess25[8]<-mean(mydata[mydata$Sess==25,"ActualSlow.8."])
AvgActualSlowSess25[9]<-mean(mydata[mydata$Sess==25,"ActualSlow.9."])
AvgActualSlowSess25[10]<-mean(mydata[mydata$Sess==25,"ActualSlow.10."])
AvgActualSlowSess25[11]<-mean(mydata[mydata$Sess==25,"ActualSlow.11."])
AvgActualSlowSess25[12]<-mean(mydata[mydata$Sess==25,"ActualSlow.12."])
AvgActualSlowSess25[13]<-mean(mydata[mydata$Sess==25,"ActualSlow.13."])
AvgActualSlowSess25[14]<-mean(mydata[mydata$Sess==25,"ActualSlow.14."])
AvgActualSlowSess25[15]<-mean(mydata[mydata$Sess==25,"ActualSlow.15."])
AvgActualSlowSess25[16]<-mean(mydata[mydata$Sess==25,"ActualSlow.16."])
AvgActualSlowSess25[17]<-mean(mydata[mydata$Sess==25,"ActualSlow.17."])
AvgActualSlowSess25[18]<-mean(mydata[mydata$Sess==25,"ActualSlow.18."])
AvgActualSlowSess25[19]<-mean(mydata[mydata$Sess==25,"ActualSlow.19."])
AvgActualSlowSess25[20]<-mean(mydata[mydata$Sess==25,"ActualSlow.20."])
AvgActualSlowSess25[21]<-mean(mydata[mydata$Sess==25,"ActualSlow.21."])
AvgActualSlowSess25[22]<-mean(mydata[mydata$Sess==25,"ActualSlow.22."])
AvgActualSlowSess25[23]<-mean(mydata[mydata$Sess==25,"ActualSlow.23."])
AvgActualSlowSess25[24]<-mean(mydata[mydata$Sess==25,"ActualSlow.24."])
AvgActualSlowSess25[25]<-mean(mydata[mydata$Sess==25,"ActualSlow.25."])
AvgActualAutoSess25<-numeric(25)
AvgActualAutoSess25[1]<-mean(mydata[mydata$Sess==25,"ActualAuto.1."])
AvgActualAutoSess25[2]<-mean(mydata[mydata$Sess==25,"ActualAuto.2."])
AvgActualAutoSess25[3]<-mean(mydata[mydata$Sess==25,"ActualAuto.3."])
AvgActualAutoSess25[4]<-mean(mydata[mydata$Sess==25,"ActualAuto.4."])
AvgActualAutoSess25[5]<-mean(mydata[mydata$Sess==25,"ActualAuto.5."])
AvgActualAutoSess25[6]<-mean(mydata[mydata$Sess==25,"ActualAuto.6."])
AvgActualAutoSess25[7]<-mean(mydata[mydata$Sess==25,"ActualAuto.7."])
AvgActualAutoSess25[8]<-mean(mydata[mydata$Sess==25,"ActualAuto.8."])
AvgActualAutoSess25[9]<-mean(mydata[mydata$Sess==25,"ActualAuto.9."])
AvgActualAutoSess25[10]<-mean(mydata[mydata$Sess==25,"ActualAuto.10."])
AvgActualAutoSess25[11]<-mean(mydata[mydata$Sess==25,"ActualAuto.11."])
AvgActualAutoSess25[12]<-mean(mydata[mydata$Sess==25,"ActualAuto.12."])
AvgActualAutoSess25[13]<-mean(mydata[mydata$Sess==25,"ActualAuto.13."])
AvgActualAutoSess25[14]<-mean(mydata[mydata$Sess==25,"ActualAuto.14."])
AvgActualAutoSess25[15]<-mean(mydata[mydata$Sess==25,"ActualAuto.15."])
AvgActualAutoSess25[16]<-mean(mydata[mydata$Sess==25,"ActualAuto.16."])
AvgActualAutoSess25[17]<-mean(mydata[mydata$Sess==25,"ActualAuto.17."])
AvgActualAutoSess25[18]<-mean(mydata[mydata$Sess==25,"ActualAuto.18."])
AvgActualAutoSess25[19]<-mean(mydata[mydata$Sess==25,"ActualAuto.19."])
AvgActualAutoSess25[20]<-mean(mydata[mydata$Sess==25,"ActualAuto.20."])
AvgActualAutoSess25[21]<-mean(mydata[mydata$Sess==25,"ActualAuto.21."])
AvgActualAutoSess25[22]<-mean(mydata[mydata$Sess==25,"ActualAuto.22."])
AvgActualAutoSess25[23]<-mean(mydata[mydata$Sess==25,"ActualAuto.23."])
AvgActualAutoSess25[24]<-mean(mydata[mydata$Sess==25,"ActualAuto.24."])
AvgActualAutoSess25[25]<-mean(mydata[mydata$Sess==25,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess25, AvgActualSlowSess25, AvgActualAutoSess25)
Sess25PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess25, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess25, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess25, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 25 (Punishment 2)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess25PlotActual

Auto <- jitter(AvgActualAutoSess25)
Slow <- jitter(AvgActualSlowSess25)
Fast <- jitter(AvgActualFastSess25)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess25TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess25TriActual


Auto <- jitter(AvgActualAutoSess25)
Slow <- jitter(AvgActualSlowSess25)
Fast <- jitter(AvgActualFastSess25)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess25Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 25 - Punishment 2') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess25Tri2Actual


#Plot for Session 26
AvgActualFastSess26<-numeric(25)
AvgActualFastSess26[1]<-mean(mydata[mydata$Sess==26,"ActualFast.1."])
AvgActualFastSess26[2]<-mean(mydata[mydata$Sess==26,"ActualFast.2."])
AvgActualFastSess26[3]<-mean(mydata[mydata$Sess==26,"ActualFast.3."])
AvgActualFastSess26[4]<-mean(mydata[mydata$Sess==26,"ActualFast.4."])
AvgActualFastSess26[5]<-mean(mydata[mydata$Sess==26,"ActualFast.5."])
AvgActualFastSess26[6]<-mean(mydata[mydata$Sess==26,"ActualFast.6."])
AvgActualFastSess26[7]<-mean(mydata[mydata$Sess==26,"ActualFast.7."])
AvgActualFastSess26[8]<-mean(mydata[mydata$Sess==26,"ActualFast.8."])
AvgActualFastSess26[9]<-mean(mydata[mydata$Sess==26,"ActualFast.9."])
AvgActualFastSess26[10]<-mean(mydata[mydata$Sess==26,"ActualFast.10."])
AvgActualFastSess26[11]<-mean(mydata[mydata$Sess==26,"ActualFast.11."])
AvgActualFastSess26[12]<-mean(mydata[mydata$Sess==26,"ActualFast.12."])
AvgActualFastSess26[13]<-mean(mydata[mydata$Sess==26,"ActualFast.13."])
AvgActualFastSess26[14]<-mean(mydata[mydata$Sess==26,"ActualFast.14."])
AvgActualFastSess26[15]<-mean(mydata[mydata$Sess==26,"ActualFast.15."])
AvgActualFastSess26[16]<-mean(mydata[mydata$Sess==26,"ActualFast.16."])
AvgActualFastSess26[17]<-mean(mydata[mydata$Sess==26,"ActualFast.17."])
AvgActualFastSess26[18]<-mean(mydata[mydata$Sess==26,"ActualFast.18."])
AvgActualFastSess26[19]<-mean(mydata[mydata$Sess==26,"ActualFast.19."])
AvgActualFastSess26[20]<-mean(mydata[mydata$Sess==26,"ActualFast.20."])
AvgActualFastSess26[21]<-mean(mydata[mydata$Sess==26,"ActualFast.21."])
AvgActualFastSess26[22]<-mean(mydata[mydata$Sess==26,"ActualFast.22."])
AvgActualFastSess26[23]<-mean(mydata[mydata$Sess==26,"ActualFast.23."])
AvgActualFastSess26[24]<-mean(mydata[mydata$Sess==26,"ActualFast.24."])
AvgActualFastSess26[25]<-mean(mydata[mydata$Sess==26,"ActualFast.25."])
AvgActualSlowSess26<-numeric(25)
AvgActualSlowSess26[1]<-mean(mydata[mydata$Sess==26,"ActualSlow.1."])
AvgActualSlowSess26[2]<-mean(mydata[mydata$Sess==26,"ActualSlow.2."])
AvgActualSlowSess26[3]<-mean(mydata[mydata$Sess==26,"ActualSlow.3."])
AvgActualSlowSess26[4]<-mean(mydata[mydata$Sess==26,"ActualSlow.4."])
AvgActualSlowSess26[5]<-mean(mydata[mydata$Sess==26,"ActualSlow.5."])
AvgActualSlowSess26[6]<-mean(mydata[mydata$Sess==26,"ActualSlow.6."])
AvgActualSlowSess26[7]<-mean(mydata[mydata$Sess==26,"ActualSlow.7."])
AvgActualSlowSess26[8]<-mean(mydata[mydata$Sess==26,"ActualSlow.8."])
AvgActualSlowSess26[9]<-mean(mydata[mydata$Sess==26,"ActualSlow.9."])
AvgActualSlowSess26[10]<-mean(mydata[mydata$Sess==26,"ActualSlow.10."])
AvgActualSlowSess26[11]<-mean(mydata[mydata$Sess==26,"ActualSlow.11."])
AvgActualSlowSess26[12]<-mean(mydata[mydata$Sess==26,"ActualSlow.12."])
AvgActualSlowSess26[13]<-mean(mydata[mydata$Sess==26,"ActualSlow.13."])
AvgActualSlowSess26[14]<-mean(mydata[mydata$Sess==26,"ActualSlow.14."])
AvgActualSlowSess26[15]<-mean(mydata[mydata$Sess==26,"ActualSlow.15."])
AvgActualSlowSess26[16]<-mean(mydata[mydata$Sess==26,"ActualSlow.16."])
AvgActualSlowSess26[17]<-mean(mydata[mydata$Sess==26,"ActualSlow.17."])
AvgActualSlowSess26[18]<-mean(mydata[mydata$Sess==26,"ActualSlow.18."])
AvgActualSlowSess26[19]<-mean(mydata[mydata$Sess==26,"ActualSlow.19."])
AvgActualSlowSess26[20]<-mean(mydata[mydata$Sess==26,"ActualSlow.20."])
AvgActualSlowSess26[21]<-mean(mydata[mydata$Sess==26,"ActualSlow.21."])
AvgActualSlowSess26[22]<-mean(mydata[mydata$Sess==26,"ActualSlow.22."])
AvgActualSlowSess26[23]<-mean(mydata[mydata$Sess==26,"ActualSlow.23."])
AvgActualSlowSess26[24]<-mean(mydata[mydata$Sess==26,"ActualSlow.24."])
AvgActualSlowSess26[25]<-mean(mydata[mydata$Sess==26,"ActualSlow.25."])
AvgActualAutoSess26<-numeric(25)
AvgActualAutoSess26[1]<-mean(mydata[mydata$Sess==26,"ActualAuto.1."])
AvgActualAutoSess26[2]<-mean(mydata[mydata$Sess==26,"ActualAuto.2."])
AvgActualAutoSess26[3]<-mean(mydata[mydata$Sess==26,"ActualAuto.3."])
AvgActualAutoSess26[4]<-mean(mydata[mydata$Sess==26,"ActualAuto.4."])
AvgActualAutoSess26[5]<-mean(mydata[mydata$Sess==26,"ActualAuto.5."])
AvgActualAutoSess26[6]<-mean(mydata[mydata$Sess==26,"ActualAuto.6."])
AvgActualAutoSess26[7]<-mean(mydata[mydata$Sess==26,"ActualAuto.7."])
AvgActualAutoSess26[8]<-mean(mydata[mydata$Sess==26,"ActualAuto.8."])
AvgActualAutoSess26[9]<-mean(mydata[mydata$Sess==26,"ActualAuto.9."])
AvgActualAutoSess26[10]<-mean(mydata[mydata$Sess==26,"ActualAuto.10."])
AvgActualAutoSess26[11]<-mean(mydata[mydata$Sess==26,"ActualAuto.11."])
AvgActualAutoSess26[12]<-mean(mydata[mydata$Sess==26,"ActualAuto.12."])
AvgActualAutoSess26[13]<-mean(mydata[mydata$Sess==26,"ActualAuto.13."])
AvgActualAutoSess26[14]<-mean(mydata[mydata$Sess==26,"ActualAuto.14."])
AvgActualAutoSess26[15]<-mean(mydata[mydata$Sess==26,"ActualAuto.15."])
AvgActualAutoSess26[16]<-mean(mydata[mydata$Sess==26,"ActualAuto.16."])
AvgActualAutoSess26[17]<-mean(mydata[mydata$Sess==26,"ActualAuto.17."])
AvgActualAutoSess26[18]<-mean(mydata[mydata$Sess==26,"ActualAuto.18."])
AvgActualAutoSess26[19]<-mean(mydata[mydata$Sess==26,"ActualAuto.19."])
AvgActualAutoSess26[20]<-mean(mydata[mydata$Sess==26,"ActualAuto.20."])
AvgActualAutoSess26[21]<-mean(mydata[mydata$Sess==26,"ActualAuto.21."])
AvgActualAutoSess26[22]<-mean(mydata[mydata$Sess==26,"ActualAuto.22."])
AvgActualAutoSess26[23]<-mean(mydata[mydata$Sess==26,"ActualAuto.23."])
AvgActualAutoSess26[24]<-mean(mydata[mydata$Sess==26,"ActualAuto.24."])
AvgActualAutoSess26[25]<-mean(mydata[mydata$Sess==26,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess26, AvgActualSlowSess26, AvgActualAutoSess26)
Sess26PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess26, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess26, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess26, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 26 (Control 8)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess26PlotActual

Auto <- jitter(AvgActualAutoSess26)
Slow <- jitter(AvgActualSlowSess26)
Fast <- jitter(AvgActualFastSess26)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess26TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess26TriActual


Auto <- jitter(AvgActualAutoSess26)
Slow <- jitter(AvgActualSlowSess26)
Fast <- jitter(AvgActualFastSess26)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess26Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 26 - Control 8') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess26Tri2Actual


#Plot for Session 27
AvgActualFastSess27<-numeric(25)
AvgActualFastSess27[1]<-mean(mydata[mydata$Sess==27,"ActualFast.1."])
AvgActualFastSess27[2]<-mean(mydata[mydata$Sess==27,"ActualFast.2."])
AvgActualFastSess27[3]<-mean(mydata[mydata$Sess==27,"ActualFast.3."])
AvgActualFastSess27[4]<-mean(mydata[mydata$Sess==27,"ActualFast.4."])
AvgActualFastSess27[5]<-mean(mydata[mydata$Sess==27,"ActualFast.5."])
AvgActualFastSess27[6]<-mean(mydata[mydata$Sess==27,"ActualFast.6."])
AvgActualFastSess27[7]<-mean(mydata[mydata$Sess==27,"ActualFast.7."])
AvgActualFastSess27[8]<-mean(mydata[mydata$Sess==27,"ActualFast.8."])
AvgActualFastSess27[9]<-mean(mydata[mydata$Sess==27,"ActualFast.9."])
AvgActualFastSess27[10]<-mean(mydata[mydata$Sess==27,"ActualFast.10."])
AvgActualFastSess27[11]<-mean(mydata[mydata$Sess==27,"ActualFast.11."])
AvgActualFastSess27[12]<-mean(mydata[mydata$Sess==27,"ActualFast.12."])
AvgActualFastSess27[13]<-mean(mydata[mydata$Sess==27,"ActualFast.13."])
AvgActualFastSess27[14]<-mean(mydata[mydata$Sess==27,"ActualFast.14."])
AvgActualFastSess27[15]<-mean(mydata[mydata$Sess==27,"ActualFast.15."])
AvgActualFastSess27[16]<-mean(mydata[mydata$Sess==27,"ActualFast.16."])
AvgActualFastSess27[17]<-mean(mydata[mydata$Sess==27,"ActualFast.17."])
AvgActualFastSess27[18]<-mean(mydata[mydata$Sess==27,"ActualFast.18."])
AvgActualFastSess27[19]<-mean(mydata[mydata$Sess==27,"ActualFast.19."])
AvgActualFastSess27[20]<-mean(mydata[mydata$Sess==27,"ActualFast.20."])
AvgActualFastSess27[21]<-mean(mydata[mydata$Sess==27,"ActualFast.21."])
AvgActualFastSess27[22]<-mean(mydata[mydata$Sess==27,"ActualFast.22."])
AvgActualFastSess27[23]<-mean(mydata[mydata$Sess==27,"ActualFast.23."])
AvgActualFastSess27[24]<-mean(mydata[mydata$Sess==27,"ActualFast.24."])
AvgActualFastSess27[25]<-mean(mydata[mydata$Sess==27,"ActualFast.25."])
AvgActualSlowSess27<-numeric(25)
AvgActualSlowSess27[1]<-mean(mydata[mydata$Sess==27,"ActualSlow.1."])
AvgActualSlowSess27[2]<-mean(mydata[mydata$Sess==27,"ActualSlow.2."])
AvgActualSlowSess27[3]<-mean(mydata[mydata$Sess==27,"ActualSlow.3."])
AvgActualSlowSess27[4]<-mean(mydata[mydata$Sess==27,"ActualSlow.4."])
AvgActualSlowSess27[5]<-mean(mydata[mydata$Sess==27,"ActualSlow.5."])
AvgActualSlowSess27[6]<-mean(mydata[mydata$Sess==27,"ActualSlow.6."])
AvgActualSlowSess27[7]<-mean(mydata[mydata$Sess==27,"ActualSlow.7."])
AvgActualSlowSess27[8]<-mean(mydata[mydata$Sess==27,"ActualSlow.8."])
AvgActualSlowSess27[9]<-mean(mydata[mydata$Sess==27,"ActualSlow.9."])
AvgActualSlowSess27[10]<-mean(mydata[mydata$Sess==27,"ActualSlow.10."])
AvgActualSlowSess27[11]<-mean(mydata[mydata$Sess==27,"ActualSlow.11."])
AvgActualSlowSess27[12]<-mean(mydata[mydata$Sess==27,"ActualSlow.12."])
AvgActualSlowSess27[13]<-mean(mydata[mydata$Sess==27,"ActualSlow.13."])
AvgActualSlowSess27[14]<-mean(mydata[mydata$Sess==27,"ActualSlow.14."])
AvgActualSlowSess27[15]<-mean(mydata[mydata$Sess==27,"ActualSlow.15."])
AvgActualSlowSess27[16]<-mean(mydata[mydata$Sess==27,"ActualSlow.16."])
AvgActualSlowSess27[17]<-mean(mydata[mydata$Sess==27,"ActualSlow.17."])
AvgActualSlowSess27[18]<-mean(mydata[mydata$Sess==27,"ActualSlow.18."])
AvgActualSlowSess27[19]<-mean(mydata[mydata$Sess==27,"ActualSlow.19."])
AvgActualSlowSess27[20]<-mean(mydata[mydata$Sess==27,"ActualSlow.20."])
AvgActualSlowSess27[21]<-mean(mydata[mydata$Sess==27,"ActualSlow.21."])
AvgActualSlowSess27[22]<-mean(mydata[mydata$Sess==27,"ActualSlow.22."])
AvgActualSlowSess27[23]<-mean(mydata[mydata$Sess==27,"ActualSlow.23."])
AvgActualSlowSess27[24]<-mean(mydata[mydata$Sess==27,"ActualSlow.24."])
AvgActualSlowSess27[25]<-mean(mydata[mydata$Sess==27,"ActualSlow.25."])
AvgActualAutoSess27<-numeric(25)
AvgActualAutoSess27[1]<-mean(mydata[mydata$Sess==27,"ActualAuto.1."])
AvgActualAutoSess27[2]<-mean(mydata[mydata$Sess==27,"ActualAuto.2."])
AvgActualAutoSess27[3]<-mean(mydata[mydata$Sess==27,"ActualAuto.3."])
AvgActualAutoSess27[4]<-mean(mydata[mydata$Sess==27,"ActualAuto.4."])
AvgActualAutoSess27[5]<-mean(mydata[mydata$Sess==27,"ActualAuto.5."])
AvgActualAutoSess27[6]<-mean(mydata[mydata$Sess==27,"ActualAuto.6."])
AvgActualAutoSess27[7]<-mean(mydata[mydata$Sess==27,"ActualAuto.7."])
AvgActualAutoSess27[8]<-mean(mydata[mydata$Sess==27,"ActualAuto.8."])
AvgActualAutoSess27[9]<-mean(mydata[mydata$Sess==27,"ActualAuto.9."])
AvgActualAutoSess27[10]<-mean(mydata[mydata$Sess==27,"ActualAuto.10."])
AvgActualAutoSess27[11]<-mean(mydata[mydata$Sess==27,"ActualAuto.11."])
AvgActualAutoSess27[12]<-mean(mydata[mydata$Sess==27,"ActualAuto.12."])
AvgActualAutoSess27[13]<-mean(mydata[mydata$Sess==27,"ActualAuto.13."])
AvgActualAutoSess27[14]<-mean(mydata[mydata$Sess==27,"ActualAuto.14."])
AvgActualAutoSess27[15]<-mean(mydata[mydata$Sess==27,"ActualAuto.15."])
AvgActualAutoSess27[16]<-mean(mydata[mydata$Sess==27,"ActualAuto.16."])
AvgActualAutoSess27[17]<-mean(mydata[mydata$Sess==27,"ActualAuto.17."])
AvgActualAutoSess27[18]<-mean(mydata[mydata$Sess==27,"ActualAuto.18."])
AvgActualAutoSess27[19]<-mean(mydata[mydata$Sess==27,"ActualAuto.19."])
AvgActualAutoSess27[20]<-mean(mydata[mydata$Sess==27,"ActualAuto.20."])
AvgActualAutoSess27[21]<-mean(mydata[mydata$Sess==27,"ActualAuto.21."])
AvgActualAutoSess27[22]<-mean(mydata[mydata$Sess==27,"ActualAuto.22."])
AvgActualAutoSess27[23]<-mean(mydata[mydata$Sess==27,"ActualAuto.23."])
AvgActualAutoSess27[24]<-mean(mydata[mydata$Sess==27,"ActualAuto.24."])
AvgActualAutoSess27[25]<-mean(mydata[mydata$Sess==27,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess27, AvgActualSlowSess27, AvgActualAutoSess27)
Sess27PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess27, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess27, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess27, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 27 (Punishment 3)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess27PlotActual

Auto <- jitter(AvgActualAutoSess27)
Slow <- jitter(AvgActualSlowSess27)
Fast <- jitter(AvgActualFastSess27)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess27TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess27TriActual


Auto <- jitter(AvgActualAutoSess27)
Slow <- jitter(AvgActualSlowSess27)
Fast <- jitter(AvgActualFastSess27)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess27Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 27 - Punishment 3') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess27Tri2Actual


#Plot for Session 28
AvgActualFastSess28<-numeric(25)
AvgActualFastSess28[1]<-mean(mydata[mydata$Sess==28,"ActualFast.1."])
AvgActualFastSess28[2]<-mean(mydata[mydata$Sess==28,"ActualFast.2."])
AvgActualFastSess28[3]<-mean(mydata[mydata$Sess==28,"ActualFast.3."])
AvgActualFastSess28[4]<-mean(mydata[mydata$Sess==28,"ActualFast.4."])
AvgActualFastSess28[5]<-mean(mydata[mydata$Sess==28,"ActualFast.5."])
AvgActualFastSess28[6]<-mean(mydata[mydata$Sess==28,"ActualFast.6."])
AvgActualFastSess28[7]<-mean(mydata[mydata$Sess==28,"ActualFast.7."])
AvgActualFastSess28[8]<-mean(mydata[mydata$Sess==28,"ActualFast.8."])
AvgActualFastSess28[9]<-mean(mydata[mydata$Sess==28,"ActualFast.9."])
AvgActualFastSess28[10]<-mean(mydata[mydata$Sess==28,"ActualFast.10."])
AvgActualFastSess28[11]<-mean(mydata[mydata$Sess==28,"ActualFast.11."])
AvgActualFastSess28[12]<-mean(mydata[mydata$Sess==28,"ActualFast.12."])
AvgActualFastSess28[13]<-mean(mydata[mydata$Sess==28,"ActualFast.13."])
AvgActualFastSess28[14]<-mean(mydata[mydata$Sess==28,"ActualFast.14."])
AvgActualFastSess28[15]<-mean(mydata[mydata$Sess==28,"ActualFast.15."])
AvgActualFastSess28[16]<-mean(mydata[mydata$Sess==28,"ActualFast.16."])
AvgActualFastSess28[17]<-mean(mydata[mydata$Sess==28,"ActualFast.17."])
AvgActualFastSess28[18]<-mean(mydata[mydata$Sess==28,"ActualFast.18."])
AvgActualFastSess28[19]<-mean(mydata[mydata$Sess==28,"ActualFast.19."])
AvgActualFastSess28[20]<-mean(mydata[mydata$Sess==28,"ActualFast.20."])
AvgActualFastSess28[21]<-mean(mydata[mydata$Sess==28,"ActualFast.21."])
AvgActualFastSess28[22]<-mean(mydata[mydata$Sess==28,"ActualFast.22."])
AvgActualFastSess28[23]<-mean(mydata[mydata$Sess==28,"ActualFast.23."])
AvgActualFastSess28[24]<-mean(mydata[mydata$Sess==28,"ActualFast.24."])
AvgActualFastSess28[25]<-mean(mydata[mydata$Sess==28,"ActualFast.25."])
AvgActualSlowSess28<-numeric(25)
AvgActualSlowSess28[1]<-mean(mydata[mydata$Sess==28,"ActualSlow.1."])
AvgActualSlowSess28[2]<-mean(mydata[mydata$Sess==28,"ActualSlow.2."])
AvgActualSlowSess28[3]<-mean(mydata[mydata$Sess==28,"ActualSlow.3."])
AvgActualSlowSess28[4]<-mean(mydata[mydata$Sess==28,"ActualSlow.4."])
AvgActualSlowSess28[5]<-mean(mydata[mydata$Sess==28,"ActualSlow.5."])
AvgActualSlowSess28[6]<-mean(mydata[mydata$Sess==28,"ActualSlow.6."])
AvgActualSlowSess28[7]<-mean(mydata[mydata$Sess==28,"ActualSlow.7."])
AvgActualSlowSess28[8]<-mean(mydata[mydata$Sess==28,"ActualSlow.8."])
AvgActualSlowSess28[9]<-mean(mydata[mydata$Sess==28,"ActualSlow.9."])
AvgActualSlowSess28[10]<-mean(mydata[mydata$Sess==28,"ActualSlow.10."])
AvgActualSlowSess28[11]<-mean(mydata[mydata$Sess==28,"ActualSlow.11."])
AvgActualSlowSess28[12]<-mean(mydata[mydata$Sess==28,"ActualSlow.12."])
AvgActualSlowSess28[13]<-mean(mydata[mydata$Sess==28,"ActualSlow.13."])
AvgActualSlowSess28[14]<-mean(mydata[mydata$Sess==28,"ActualSlow.14."])
AvgActualSlowSess28[15]<-mean(mydata[mydata$Sess==28,"ActualSlow.15."])
AvgActualSlowSess28[16]<-mean(mydata[mydata$Sess==28,"ActualSlow.16."])
AvgActualSlowSess28[17]<-mean(mydata[mydata$Sess==28,"ActualSlow.17."])
AvgActualSlowSess28[18]<-mean(mydata[mydata$Sess==28,"ActualSlow.18."])
AvgActualSlowSess28[19]<-mean(mydata[mydata$Sess==28,"ActualSlow.19."])
AvgActualSlowSess28[20]<-mean(mydata[mydata$Sess==28,"ActualSlow.20."])
AvgActualSlowSess28[21]<-mean(mydata[mydata$Sess==28,"ActualSlow.21."])
AvgActualSlowSess28[22]<-mean(mydata[mydata$Sess==28,"ActualSlow.22."])
AvgActualSlowSess28[23]<-mean(mydata[mydata$Sess==28,"ActualSlow.23."])
AvgActualSlowSess28[24]<-mean(mydata[mydata$Sess==28,"ActualSlow.24."])
AvgActualSlowSess28[25]<-mean(mydata[mydata$Sess==28,"ActualSlow.25."])
AvgActualAutoSess28<-numeric(25)
AvgActualAutoSess28[1]<-mean(mydata[mydata$Sess==28,"ActualAuto.1."])
AvgActualAutoSess28[2]<-mean(mydata[mydata$Sess==28,"ActualAuto.2."])
AvgActualAutoSess28[3]<-mean(mydata[mydata$Sess==28,"ActualAuto.3."])
AvgActualAutoSess28[4]<-mean(mydata[mydata$Sess==28,"ActualAuto.4."])
AvgActualAutoSess28[5]<-mean(mydata[mydata$Sess==28,"ActualAuto.5."])
AvgActualAutoSess28[6]<-mean(mydata[mydata$Sess==28,"ActualAuto.6."])
AvgActualAutoSess28[7]<-mean(mydata[mydata$Sess==28,"ActualAuto.7."])
AvgActualAutoSess28[8]<-mean(mydata[mydata$Sess==28,"ActualAuto.8."])
AvgActualAutoSess28[9]<-mean(mydata[mydata$Sess==28,"ActualAuto.9."])
AvgActualAutoSess28[10]<-mean(mydata[mydata$Sess==28,"ActualAuto.10."])
AvgActualAutoSess28[11]<-mean(mydata[mydata$Sess==28,"ActualAuto.11."])
AvgActualAutoSess28[12]<-mean(mydata[mydata$Sess==28,"ActualAuto.12."])
AvgActualAutoSess28[13]<-mean(mydata[mydata$Sess==28,"ActualAuto.13."])
AvgActualAutoSess28[14]<-mean(mydata[mydata$Sess==28,"ActualAuto.14."])
AvgActualAutoSess28[15]<-mean(mydata[mydata$Sess==28,"ActualAuto.15."])
AvgActualAutoSess28[16]<-mean(mydata[mydata$Sess==28,"ActualAuto.16."])
AvgActualAutoSess28[17]<-mean(mydata[mydata$Sess==28,"ActualAuto.17."])
AvgActualAutoSess28[18]<-mean(mydata[mydata$Sess==28,"ActualAuto.18."])
AvgActualAutoSess28[19]<-mean(mydata[mydata$Sess==28,"ActualAuto.19."])
AvgActualAutoSess28[20]<-mean(mydata[mydata$Sess==28,"ActualAuto.20."])
AvgActualAutoSess28[21]<-mean(mydata[mydata$Sess==28,"ActualAuto.21."])
AvgActualAutoSess28[22]<-mean(mydata[mydata$Sess==28,"ActualAuto.22."])
AvgActualAutoSess28[23]<-mean(mydata[mydata$Sess==28,"ActualAuto.23."])
AvgActualAutoSess28[24]<-mean(mydata[mydata$Sess==28,"ActualAuto.24."])
AvgActualAutoSess28[25]<-mean(mydata[mydata$Sess==28,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess28, AvgActualSlowSess28, AvgActualAutoSess28)
Sess28PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess28, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess28, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess28, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 28 (Punishment 4)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess28PlotActual

Auto <- jitter(AvgActualAutoSess28)
Slow <- jitter(AvgActualSlowSess28)
Fast <- jitter(AvgActualFastSess28)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess28TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess28TriActual


Auto <- jitter(AvgActualAutoSess28)
Slow <- jitter(AvgActualSlowSess28)
Fast <- jitter(AvgActualFastSess28)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess28Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 28 - Punishment 4') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess28Tri2Actual



#Plot for Session 29
AvgActualFastSess29<-numeric(25)
AvgActualFastSess29[1]<-mean(mydata[mydata$Sess==29,"ActualFast.1."])
AvgActualFastSess29[2]<-mean(mydata[mydata$Sess==29,"ActualFast.2."])
AvgActualFastSess29[3]<-mean(mydata[mydata$Sess==29,"ActualFast.3."])
AvgActualFastSess29[4]<-mean(mydata[mydata$Sess==29,"ActualFast.4."])
AvgActualFastSess29[5]<-mean(mydata[mydata$Sess==29,"ActualFast.5."])
AvgActualFastSess29[6]<-mean(mydata[mydata$Sess==29,"ActualFast.6."])
AvgActualFastSess29[7]<-mean(mydata[mydata$Sess==29,"ActualFast.7."])
AvgActualFastSess29[8]<-mean(mydata[mydata$Sess==29,"ActualFast.8."])
AvgActualFastSess29[9]<-mean(mydata[mydata$Sess==29,"ActualFast.9."])
AvgActualFastSess29[10]<-mean(mydata[mydata$Sess==29,"ActualFast.10."])
AvgActualFastSess29[11]<-mean(mydata[mydata$Sess==29,"ActualFast.11."])
AvgActualFastSess29[12]<-mean(mydata[mydata$Sess==29,"ActualFast.12."])
AvgActualFastSess29[13]<-mean(mydata[mydata$Sess==29,"ActualFast.13."])
AvgActualFastSess29[14]<-mean(mydata[mydata$Sess==29,"ActualFast.14."])
AvgActualFastSess29[15]<-mean(mydata[mydata$Sess==29,"ActualFast.15."])
AvgActualFastSess29[16]<-mean(mydata[mydata$Sess==29,"ActualFast.16."])
AvgActualFastSess29[17]<-mean(mydata[mydata$Sess==29,"ActualFast.17."])
AvgActualFastSess29[18]<-mean(mydata[mydata$Sess==29,"ActualFast.18."])
AvgActualFastSess29[19]<-mean(mydata[mydata$Sess==29,"ActualFast.19."])
AvgActualFastSess29[20]<-mean(mydata[mydata$Sess==29,"ActualFast.20."])
AvgActualFastSess29[21]<-mean(mydata[mydata$Sess==29,"ActualFast.21."])
AvgActualFastSess29[22]<-mean(mydata[mydata$Sess==29,"ActualFast.22."])
AvgActualFastSess29[23]<-mean(mydata[mydata$Sess==29,"ActualFast.23."])
AvgActualFastSess29[24]<-mean(mydata[mydata$Sess==29,"ActualFast.24."])
AvgActualFastSess29[25]<-mean(mydata[mydata$Sess==29,"ActualFast.25."])
AvgActualSlowSess29<-numeric(25)
AvgActualSlowSess29[1]<-mean(mydata[mydata$Sess==29,"ActualSlow.1."])
AvgActualSlowSess29[2]<-mean(mydata[mydata$Sess==29,"ActualSlow.2."])
AvgActualSlowSess29[3]<-mean(mydata[mydata$Sess==29,"ActualSlow.3."])
AvgActualSlowSess29[4]<-mean(mydata[mydata$Sess==29,"ActualSlow.4."])
AvgActualSlowSess29[5]<-mean(mydata[mydata$Sess==29,"ActualSlow.5."])
AvgActualSlowSess29[6]<-mean(mydata[mydata$Sess==29,"ActualSlow.6."])
AvgActualSlowSess29[7]<-mean(mydata[mydata$Sess==29,"ActualSlow.7."])
AvgActualSlowSess29[8]<-mean(mydata[mydata$Sess==29,"ActualSlow.8."])
AvgActualSlowSess29[9]<-mean(mydata[mydata$Sess==29,"ActualSlow.9."])
AvgActualSlowSess29[10]<-mean(mydata[mydata$Sess==29,"ActualSlow.10."])
AvgActualSlowSess29[11]<-mean(mydata[mydata$Sess==29,"ActualSlow.11."])
AvgActualSlowSess29[12]<-mean(mydata[mydata$Sess==29,"ActualSlow.12."])
AvgActualSlowSess29[13]<-mean(mydata[mydata$Sess==29,"ActualSlow.13."])
AvgActualSlowSess29[14]<-mean(mydata[mydata$Sess==29,"ActualSlow.14."])
AvgActualSlowSess29[15]<-mean(mydata[mydata$Sess==29,"ActualSlow.15."])
AvgActualSlowSess29[16]<-mean(mydata[mydata$Sess==29,"ActualSlow.16."])
AvgActualSlowSess29[17]<-mean(mydata[mydata$Sess==29,"ActualSlow.17."])
AvgActualSlowSess29[18]<-mean(mydata[mydata$Sess==29,"ActualSlow.18."])
AvgActualSlowSess29[19]<-mean(mydata[mydata$Sess==29,"ActualSlow.19."])
AvgActualSlowSess29[20]<-mean(mydata[mydata$Sess==29,"ActualSlow.20."])
AvgActualSlowSess29[21]<-mean(mydata[mydata$Sess==29,"ActualSlow.21."])
AvgActualSlowSess29[22]<-mean(mydata[mydata$Sess==29,"ActualSlow.22."])
AvgActualSlowSess29[23]<-mean(mydata[mydata$Sess==29,"ActualSlow.23."])
AvgActualSlowSess29[24]<-mean(mydata[mydata$Sess==29,"ActualSlow.24."])
AvgActualSlowSess29[25]<-mean(mydata[mydata$Sess==29,"ActualSlow.25."])
AvgActualAutoSess29<-numeric(25)
AvgActualAutoSess29[1]<-mean(mydata[mydata$Sess==29,"ActualAuto.1."])
AvgActualAutoSess29[2]<-mean(mydata[mydata$Sess==29,"ActualAuto.2."])
AvgActualAutoSess29[3]<-mean(mydata[mydata$Sess==29,"ActualAuto.3."])
AvgActualAutoSess29[4]<-mean(mydata[mydata$Sess==29,"ActualAuto.4."])
AvgActualAutoSess29[5]<-mean(mydata[mydata$Sess==29,"ActualAuto.5."])
AvgActualAutoSess29[6]<-mean(mydata[mydata$Sess==29,"ActualAuto.6."])
AvgActualAutoSess29[7]<-mean(mydata[mydata$Sess==29,"ActualAuto.7."])
AvgActualAutoSess29[8]<-mean(mydata[mydata$Sess==29,"ActualAuto.8."])
AvgActualAutoSess29[9]<-mean(mydata[mydata$Sess==29,"ActualAuto.9."])
AvgActualAutoSess29[10]<-mean(mydata[mydata$Sess==29,"ActualAuto.10."])
AvgActualAutoSess29[11]<-mean(mydata[mydata$Sess==29,"ActualAuto.11."])
AvgActualAutoSess29[12]<-mean(mydata[mydata$Sess==29,"ActualAuto.12."])
AvgActualAutoSess29[13]<-mean(mydata[mydata$Sess==29,"ActualAuto.13."])
AvgActualAutoSess29[14]<-mean(mydata[mydata$Sess==29,"ActualAuto.14."])
AvgActualAutoSess29[15]<-mean(mydata[mydata$Sess==29,"ActualAuto.15."])
AvgActualAutoSess29[16]<-mean(mydata[mydata$Sess==29,"ActualAuto.16."])
AvgActualAutoSess29[17]<-mean(mydata[mydata$Sess==29,"ActualAuto.17."])
AvgActualAutoSess29[18]<-mean(mydata[mydata$Sess==29,"ActualAuto.18."])
AvgActualAutoSess29[19]<-mean(mydata[mydata$Sess==29,"ActualAuto.19."])
AvgActualAutoSess29[20]<-mean(mydata[mydata$Sess==29,"ActualAuto.20."])
AvgActualAutoSess29[21]<-mean(mydata[mydata$Sess==29,"ActualAuto.21."])
AvgActualAutoSess29[22]<-mean(mydata[mydata$Sess==29,"ActualAuto.22."])
AvgActualAutoSess29[23]<-mean(mydata[mydata$Sess==29,"ActualAuto.23."])
AvgActualAutoSess29[24]<-mean(mydata[mydata$Sess==29,"ActualAuto.24."])
AvgActualAutoSess29[25]<-mean(mydata[mydata$Sess==29,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess29, AvgActualSlowSess29, AvgActualAutoSess29)
Sess29PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess29, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess29, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess29, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 29 (Punishment 5)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess29PlotActual

Auto <- jitter(AvgActualAutoSess29)
Slow <- jitter(AvgActualSlowSess29)
Fast <- jitter(AvgActualFastSess29)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess29TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess29TriActual


Auto <- jitter(AvgActualAutoSess29)
Slow <- jitter(AvgActualSlowSess29)
Fast <- jitter(AvgActualFastSess29)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess29Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 29 - Punishment 5') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess29Tri2Actual


#Plot for Session 30
AvgActualFastSess30<-numeric(25)
AvgActualFastSess30[1]<-mean(mydata[mydata$Sess==30,"ActualFast.1."])
AvgActualFastSess30[2]<-mean(mydata[mydata$Sess==30,"ActualFast.2."])
AvgActualFastSess30[3]<-mean(mydata[mydata$Sess==30,"ActualFast.3."])
AvgActualFastSess30[4]<-mean(mydata[mydata$Sess==30,"ActualFast.4."])
AvgActualFastSess30[5]<-mean(mydata[mydata$Sess==30,"ActualFast.5."])
AvgActualFastSess30[6]<-mean(mydata[mydata$Sess==30,"ActualFast.6."])
AvgActualFastSess30[7]<-mean(mydata[mydata$Sess==30,"ActualFast.7."])
AvgActualFastSess30[8]<-mean(mydata[mydata$Sess==30,"ActualFast.8."])
AvgActualFastSess30[9]<-mean(mydata[mydata$Sess==30,"ActualFast.9."])
AvgActualFastSess30[10]<-mean(mydata[mydata$Sess==30,"ActualFast.10."])
AvgActualFastSess30[11]<-mean(mydata[mydata$Sess==30,"ActualFast.11."])
AvgActualFastSess30[12]<-mean(mydata[mydata$Sess==30,"ActualFast.12."])
AvgActualFastSess30[13]<-mean(mydata[mydata$Sess==30,"ActualFast.13."])
AvgActualFastSess30[14]<-mean(mydata[mydata$Sess==30,"ActualFast.14."])
AvgActualFastSess30[15]<-mean(mydata[mydata$Sess==30,"ActualFast.15."])
AvgActualFastSess30[16]<-mean(mydata[mydata$Sess==30,"ActualFast.16."])
AvgActualFastSess30[17]<-mean(mydata[mydata$Sess==30,"ActualFast.17."])
AvgActualFastSess30[18]<-mean(mydata[mydata$Sess==30,"ActualFast.18."])
AvgActualFastSess30[19]<-mean(mydata[mydata$Sess==30,"ActualFast.19."])
AvgActualFastSess30[20]<-mean(mydata[mydata$Sess==30,"ActualFast.20."])
AvgActualFastSess30[21]<-mean(mydata[mydata$Sess==30,"ActualFast.21."])
AvgActualFastSess30[22]<-mean(mydata[mydata$Sess==30,"ActualFast.22."])
AvgActualFastSess30[23]<-mean(mydata[mydata$Sess==30,"ActualFast.23."])
AvgActualFastSess30[24]<-mean(mydata[mydata$Sess==30,"ActualFast.24."])
AvgActualFastSess30[25]<-mean(mydata[mydata$Sess==30,"ActualFast.25."])
AvgActualSlowSess30<-numeric(25)
AvgActualSlowSess30[1]<-mean(mydata[mydata$Sess==30,"ActualSlow.1."])
AvgActualSlowSess30[2]<-mean(mydata[mydata$Sess==30,"ActualSlow.2."])
AvgActualSlowSess30[3]<-mean(mydata[mydata$Sess==30,"ActualSlow.3."])
AvgActualSlowSess30[4]<-mean(mydata[mydata$Sess==30,"ActualSlow.4."])
AvgActualSlowSess30[5]<-mean(mydata[mydata$Sess==30,"ActualSlow.5."])
AvgActualSlowSess30[6]<-mean(mydata[mydata$Sess==30,"ActualSlow.6."])
AvgActualSlowSess30[7]<-mean(mydata[mydata$Sess==30,"ActualSlow.7."])
AvgActualSlowSess30[8]<-mean(mydata[mydata$Sess==30,"ActualSlow.8."])
AvgActualSlowSess30[9]<-mean(mydata[mydata$Sess==30,"ActualSlow.9."])
AvgActualSlowSess30[10]<-mean(mydata[mydata$Sess==30,"ActualSlow.10."])
AvgActualSlowSess30[11]<-mean(mydata[mydata$Sess==30,"ActualSlow.11."])
AvgActualSlowSess30[12]<-mean(mydata[mydata$Sess==30,"ActualSlow.12."])
AvgActualSlowSess30[13]<-mean(mydata[mydata$Sess==30,"ActualSlow.13."])
AvgActualSlowSess30[14]<-mean(mydata[mydata$Sess==30,"ActualSlow.14."])
AvgActualSlowSess30[15]<-mean(mydata[mydata$Sess==30,"ActualSlow.15."])
AvgActualSlowSess30[16]<-mean(mydata[mydata$Sess==30,"ActualSlow.16."])
AvgActualSlowSess30[17]<-mean(mydata[mydata$Sess==30,"ActualSlow.17."])
AvgActualSlowSess30[18]<-mean(mydata[mydata$Sess==30,"ActualSlow.18."])
AvgActualSlowSess30[19]<-mean(mydata[mydata$Sess==30,"ActualSlow.19."])
AvgActualSlowSess30[20]<-mean(mydata[mydata$Sess==30,"ActualSlow.20."])
AvgActualSlowSess30[21]<-mean(mydata[mydata$Sess==30,"ActualSlow.21."])
AvgActualSlowSess30[22]<-mean(mydata[mydata$Sess==30,"ActualSlow.22."])
AvgActualSlowSess30[23]<-mean(mydata[mydata$Sess==30,"ActualSlow.23."])
AvgActualSlowSess30[24]<-mean(mydata[mydata$Sess==30,"ActualSlow.24."])
AvgActualSlowSess30[25]<-mean(mydata[mydata$Sess==30,"ActualSlow.25."])
AvgActualAutoSess30<-numeric(25)
AvgActualAutoSess30[1]<-mean(mydata[mydata$Sess==30,"ActualAuto.1."])
AvgActualAutoSess30[2]<-mean(mydata[mydata$Sess==30,"ActualAuto.2."])
AvgActualAutoSess30[3]<-mean(mydata[mydata$Sess==30,"ActualAuto.3."])
AvgActualAutoSess30[4]<-mean(mydata[mydata$Sess==30,"ActualAuto.4."])
AvgActualAutoSess30[5]<-mean(mydata[mydata$Sess==30,"ActualAuto.5."])
AvgActualAutoSess30[6]<-mean(mydata[mydata$Sess==30,"ActualAuto.6."])
AvgActualAutoSess30[7]<-mean(mydata[mydata$Sess==30,"ActualAuto.7."])
AvgActualAutoSess30[8]<-mean(mydata[mydata$Sess==30,"ActualAuto.8."])
AvgActualAutoSess30[9]<-mean(mydata[mydata$Sess==30,"ActualAuto.9."])
AvgActualAutoSess30[10]<-mean(mydata[mydata$Sess==30,"ActualAuto.10."])
AvgActualAutoSess30[11]<-mean(mydata[mydata$Sess==30,"ActualAuto.11."])
AvgActualAutoSess30[12]<-mean(mydata[mydata$Sess==30,"ActualAuto.12."])
AvgActualAutoSess30[13]<-mean(mydata[mydata$Sess==30,"ActualAuto.13."])
AvgActualAutoSess30[14]<-mean(mydata[mydata$Sess==30,"ActualAuto.14."])
AvgActualAutoSess30[15]<-mean(mydata[mydata$Sess==30,"ActualAuto.15."])
AvgActualAutoSess30[16]<-mean(mydata[mydata$Sess==30,"ActualAuto.16."])
AvgActualAutoSess30[17]<-mean(mydata[mydata$Sess==30,"ActualAuto.17."])
AvgActualAutoSess30[18]<-mean(mydata[mydata$Sess==30,"ActualAuto.18."])
AvgActualAutoSess30[19]<-mean(mydata[mydata$Sess==30,"ActualAuto.19."])
AvgActualAutoSess30[20]<-mean(mydata[mydata$Sess==30,"ActualAuto.20."])
AvgActualAutoSess30[21]<-mean(mydata[mydata$Sess==30,"ActualAuto.21."])
AvgActualAutoSess30[22]<-mean(mydata[mydata$Sess==30,"ActualAuto.22."])
AvgActualAutoSess30[23]<-mean(mydata[mydata$Sess==30,"ActualAuto.23."])
AvgActualAutoSess30[24]<-mean(mydata[mydata$Sess==30,"ActualAuto.24."])
AvgActualAutoSess30[25]<-mean(mydata[mydata$Sess==30,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess30, AvgActualSlowSess30, AvgActualAutoSess30)
Sess30PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess30, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess30, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess30, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 30 (Punishment 6)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess30PlotActual

Auto <- jitter(AvgActualAutoSess30)
Slow <- jitter(AvgActualSlowSess30)
Fast <- jitter(AvgActualFastSess30)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess30TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess30TriActual


Auto <- jitter(AvgActualAutoSess30)
Slow <- jitter(AvgActualSlowSess30)
Fast <- jitter(AvgActualFastSess30)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess30Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 30 - Punishment 6') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess30Tri2Actual


#Plot for Session 31
AvgActualFastSess31<-numeric(25)
AvgActualFastSess31[1]<-mean(mydata[mydata$Sess==31,"ActualFast.1."])
AvgActualFastSess31[2]<-mean(mydata[mydata$Sess==31,"ActualFast.2."])
AvgActualFastSess31[3]<-mean(mydata[mydata$Sess==31,"ActualFast.3."])
AvgActualFastSess31[4]<-mean(mydata[mydata$Sess==31,"ActualFast.4."])
AvgActualFastSess31[5]<-mean(mydata[mydata$Sess==31,"ActualFast.5."])
AvgActualFastSess31[6]<-mean(mydata[mydata$Sess==31,"ActualFast.6."])
AvgActualFastSess31[7]<-mean(mydata[mydata$Sess==31,"ActualFast.7."])
AvgActualFastSess31[8]<-mean(mydata[mydata$Sess==31,"ActualFast.8."])
AvgActualFastSess31[9]<-mean(mydata[mydata$Sess==31,"ActualFast.9."])
AvgActualFastSess31[10]<-mean(mydata[mydata$Sess==31,"ActualFast.10."])
AvgActualFastSess31[11]<-mean(mydata[mydata$Sess==31,"ActualFast.11."])
AvgActualFastSess31[12]<-mean(mydata[mydata$Sess==31,"ActualFast.12."])
AvgActualFastSess31[13]<-mean(mydata[mydata$Sess==31,"ActualFast.13."])
AvgActualFastSess31[14]<-mean(mydata[mydata$Sess==31,"ActualFast.14."])
AvgActualFastSess31[15]<-mean(mydata[mydata$Sess==31,"ActualFast.15."])
AvgActualFastSess31[16]<-mean(mydata[mydata$Sess==31,"ActualFast.16."])
AvgActualFastSess31[17]<-mean(mydata[mydata$Sess==31,"ActualFast.17."])
AvgActualFastSess31[18]<-mean(mydata[mydata$Sess==31,"ActualFast.18."])
AvgActualFastSess31[19]<-mean(mydata[mydata$Sess==31,"ActualFast.19."])
AvgActualFastSess31[20]<-mean(mydata[mydata$Sess==31,"ActualFast.20."])
AvgActualFastSess31[21]<-mean(mydata[mydata$Sess==31,"ActualFast.21."])
AvgActualFastSess31[22]<-mean(mydata[mydata$Sess==31,"ActualFast.22."])
AvgActualFastSess31[23]<-mean(mydata[mydata$Sess==31,"ActualFast.23."])
AvgActualFastSess31[24]<-mean(mydata[mydata$Sess==31,"ActualFast.24."])
AvgActualFastSess31[25]<-mean(mydata[mydata$Sess==31,"ActualFast.25."])
AvgActualSlowSess31<-numeric(25)
AvgActualSlowSess31[1]<-mean(mydata[mydata$Sess==31,"ActualSlow.1."])
AvgActualSlowSess31[2]<-mean(mydata[mydata$Sess==31,"ActualSlow.2."])
AvgActualSlowSess31[3]<-mean(mydata[mydata$Sess==31,"ActualSlow.3."])
AvgActualSlowSess31[4]<-mean(mydata[mydata$Sess==31,"ActualSlow.4."])
AvgActualSlowSess31[5]<-mean(mydata[mydata$Sess==31,"ActualSlow.5."])
AvgActualSlowSess31[6]<-mean(mydata[mydata$Sess==31,"ActualSlow.6."])
AvgActualSlowSess31[7]<-mean(mydata[mydata$Sess==31,"ActualSlow.7."])
AvgActualSlowSess31[8]<-mean(mydata[mydata$Sess==31,"ActualSlow.8."])
AvgActualSlowSess31[9]<-mean(mydata[mydata$Sess==31,"ActualSlow.9."])
AvgActualSlowSess31[10]<-mean(mydata[mydata$Sess==31,"ActualSlow.10."])
AvgActualSlowSess31[11]<-mean(mydata[mydata$Sess==31,"ActualSlow.11."])
AvgActualSlowSess31[12]<-mean(mydata[mydata$Sess==31,"ActualSlow.12."])
AvgActualSlowSess31[13]<-mean(mydata[mydata$Sess==31,"ActualSlow.13."])
AvgActualSlowSess31[14]<-mean(mydata[mydata$Sess==31,"ActualSlow.14."])
AvgActualSlowSess31[15]<-mean(mydata[mydata$Sess==31,"ActualSlow.15."])
AvgActualSlowSess31[16]<-mean(mydata[mydata$Sess==31,"ActualSlow.16."])
AvgActualSlowSess31[17]<-mean(mydata[mydata$Sess==31,"ActualSlow.17."])
AvgActualSlowSess31[18]<-mean(mydata[mydata$Sess==31,"ActualSlow.18."])
AvgActualSlowSess31[19]<-mean(mydata[mydata$Sess==31,"ActualSlow.19."])
AvgActualSlowSess31[20]<-mean(mydata[mydata$Sess==31,"ActualSlow.20."])
AvgActualSlowSess31[21]<-mean(mydata[mydata$Sess==31,"ActualSlow.21."])
AvgActualSlowSess31[22]<-mean(mydata[mydata$Sess==31,"ActualSlow.22."])
AvgActualSlowSess31[23]<-mean(mydata[mydata$Sess==31,"ActualSlow.23."])
AvgActualSlowSess31[24]<-mean(mydata[mydata$Sess==31,"ActualSlow.24."])
AvgActualSlowSess31[25]<-mean(mydata[mydata$Sess==31,"ActualSlow.25."])
AvgActualAutoSess31<-numeric(25)
AvgActualAutoSess31[1]<-mean(mydata[mydata$Sess==31,"ActualAuto.1."])
AvgActualAutoSess31[2]<-mean(mydata[mydata$Sess==31,"ActualAuto.2."])
AvgActualAutoSess31[3]<-mean(mydata[mydata$Sess==31,"ActualAuto.3."])
AvgActualAutoSess31[4]<-mean(mydata[mydata$Sess==31,"ActualAuto.4."])
AvgActualAutoSess31[5]<-mean(mydata[mydata$Sess==31,"ActualAuto.5."])
AvgActualAutoSess31[6]<-mean(mydata[mydata$Sess==31,"ActualAuto.6."])
AvgActualAutoSess31[7]<-mean(mydata[mydata$Sess==31,"ActualAuto.7."])
AvgActualAutoSess31[8]<-mean(mydata[mydata$Sess==31,"ActualAuto.8."])
AvgActualAutoSess31[9]<-mean(mydata[mydata$Sess==31,"ActualAuto.9."])
AvgActualAutoSess31[10]<-mean(mydata[mydata$Sess==31,"ActualAuto.10."])
AvgActualAutoSess31[11]<-mean(mydata[mydata$Sess==31,"ActualAuto.11."])
AvgActualAutoSess31[12]<-mean(mydata[mydata$Sess==31,"ActualAuto.12."])
AvgActualAutoSess31[13]<-mean(mydata[mydata$Sess==31,"ActualAuto.13."])
AvgActualAutoSess31[14]<-mean(mydata[mydata$Sess==31,"ActualAuto.14."])
AvgActualAutoSess31[15]<-mean(mydata[mydata$Sess==31,"ActualAuto.15."])
AvgActualAutoSess31[16]<-mean(mydata[mydata$Sess==31,"ActualAuto.16."])
AvgActualAutoSess31[17]<-mean(mydata[mydata$Sess==31,"ActualAuto.17."])
AvgActualAutoSess31[18]<-mean(mydata[mydata$Sess==31,"ActualAuto.18."])
AvgActualAutoSess31[19]<-mean(mydata[mydata$Sess==31,"ActualAuto.19."])
AvgActualAutoSess31[20]<-mean(mydata[mydata$Sess==31,"ActualAuto.20."])
AvgActualAutoSess31[21]<-mean(mydata[mydata$Sess==31,"ActualAuto.21."])
AvgActualAutoSess31[22]<-mean(mydata[mydata$Sess==31,"ActualAuto.22."])
AvgActualAutoSess31[23]<-mean(mydata[mydata$Sess==31,"ActualAuto.23."])
AvgActualAutoSess31[24]<-mean(mydata[mydata$Sess==31,"ActualAuto.24."])
AvgActualAutoSess31[25]<-mean(mydata[mydata$Sess==31,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess31, AvgActualSlowSess31, AvgActualAutoSess31)
Sess31PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess31, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess31, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess31, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 31 (Punishment 7)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess31PlotActual

Auto <- jitter(AvgActualAutoSess31)
Slow <- jitter(AvgActualSlowSess31)
Fast <- jitter(AvgActualFastSess31)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess31TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess31TriActual


Auto <- jitter(AvgActualAutoSess31)
Slow <- jitter(AvgActualSlowSess31)
Fast <- jitter(AvgActualFastSess31)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess31Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 31 - Punishment 7') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess31Tri2Actual


#Plot for Session 32
AvgActualFastSess32<-numeric(25)
AvgActualFastSess32[1]<-mean(mydata[mydata$Sess==32,"ActualFast.1."])
AvgActualFastSess32[2]<-mean(mydata[mydata$Sess==32,"ActualFast.2."])
AvgActualFastSess32[3]<-mean(mydata[mydata$Sess==32,"ActualFast.3."])
AvgActualFastSess32[4]<-mean(mydata[mydata$Sess==32,"ActualFast.4."])
AvgActualFastSess32[5]<-mean(mydata[mydata$Sess==32,"ActualFast.5."])
AvgActualFastSess32[6]<-mean(mydata[mydata$Sess==32,"ActualFast.6."])
AvgActualFastSess32[7]<-mean(mydata[mydata$Sess==32,"ActualFast.7."])
AvgActualFastSess32[8]<-mean(mydata[mydata$Sess==32,"ActualFast.8."])
AvgActualFastSess32[9]<-mean(mydata[mydata$Sess==32,"ActualFast.9."])
AvgActualFastSess32[10]<-mean(mydata[mydata$Sess==32,"ActualFast.10."])
AvgActualFastSess32[11]<-mean(mydata[mydata$Sess==32,"ActualFast.11."])
AvgActualFastSess32[12]<-mean(mydata[mydata$Sess==32,"ActualFast.12."])
AvgActualFastSess32[13]<-mean(mydata[mydata$Sess==32,"ActualFast.13."])
AvgActualFastSess32[14]<-mean(mydata[mydata$Sess==32,"ActualFast.14."])
AvgActualFastSess32[15]<-mean(mydata[mydata$Sess==32,"ActualFast.15."])
AvgActualFastSess32[16]<-mean(mydata[mydata$Sess==32,"ActualFast.16."])
AvgActualFastSess32[17]<-mean(mydata[mydata$Sess==32,"ActualFast.17."])
AvgActualFastSess32[18]<-mean(mydata[mydata$Sess==32,"ActualFast.18."])
AvgActualFastSess32[19]<-mean(mydata[mydata$Sess==32,"ActualFast.19."])
AvgActualFastSess32[20]<-mean(mydata[mydata$Sess==32,"ActualFast.20."])
AvgActualFastSess32[21]<-mean(mydata[mydata$Sess==32,"ActualFast.21."])
AvgActualFastSess32[22]<-mean(mydata[mydata$Sess==32,"ActualFast.22."])
AvgActualFastSess32[23]<-mean(mydata[mydata$Sess==32,"ActualFast.23."])
AvgActualFastSess32[24]<-mean(mydata[mydata$Sess==32,"ActualFast.24."])
AvgActualFastSess32[25]<-mean(mydata[mydata$Sess==32,"ActualFast.25."])
AvgActualSlowSess32<-numeric(25)
AvgActualSlowSess32[1]<-mean(mydata[mydata$Sess==32,"ActualSlow.1."])
AvgActualSlowSess32[2]<-mean(mydata[mydata$Sess==32,"ActualSlow.2."])
AvgActualSlowSess32[3]<-mean(mydata[mydata$Sess==32,"ActualSlow.3."])
AvgActualSlowSess32[4]<-mean(mydata[mydata$Sess==32,"ActualSlow.4."])
AvgActualSlowSess32[5]<-mean(mydata[mydata$Sess==32,"ActualSlow.5."])
AvgActualSlowSess32[6]<-mean(mydata[mydata$Sess==32,"ActualSlow.6."])
AvgActualSlowSess32[7]<-mean(mydata[mydata$Sess==32,"ActualSlow.7."])
AvgActualSlowSess32[8]<-mean(mydata[mydata$Sess==32,"ActualSlow.8."])
AvgActualSlowSess32[9]<-mean(mydata[mydata$Sess==32,"ActualSlow.9."])
AvgActualSlowSess32[10]<-mean(mydata[mydata$Sess==32,"ActualSlow.10."])
AvgActualSlowSess32[11]<-mean(mydata[mydata$Sess==32,"ActualSlow.11."])
AvgActualSlowSess32[12]<-mean(mydata[mydata$Sess==32,"ActualSlow.12."])
AvgActualSlowSess32[13]<-mean(mydata[mydata$Sess==32,"ActualSlow.13."])
AvgActualSlowSess32[14]<-mean(mydata[mydata$Sess==32,"ActualSlow.14."])
AvgActualSlowSess32[15]<-mean(mydata[mydata$Sess==32,"ActualSlow.15."])
AvgActualSlowSess32[16]<-mean(mydata[mydata$Sess==32,"ActualSlow.16."])
AvgActualSlowSess32[17]<-mean(mydata[mydata$Sess==32,"ActualSlow.17."])
AvgActualSlowSess32[18]<-mean(mydata[mydata$Sess==32,"ActualSlow.18."])
AvgActualSlowSess32[19]<-mean(mydata[mydata$Sess==32,"ActualSlow.19."])
AvgActualSlowSess32[20]<-mean(mydata[mydata$Sess==32,"ActualSlow.20."])
AvgActualSlowSess32[21]<-mean(mydata[mydata$Sess==32,"ActualSlow.21."])
AvgActualSlowSess32[22]<-mean(mydata[mydata$Sess==32,"ActualSlow.22."])
AvgActualSlowSess32[23]<-mean(mydata[mydata$Sess==32,"ActualSlow.23."])
AvgActualSlowSess32[24]<-mean(mydata[mydata$Sess==32,"ActualSlow.24."])
AvgActualSlowSess32[25]<-mean(mydata[mydata$Sess==32,"ActualSlow.25."])
AvgActualAutoSess32<-numeric(25)
AvgActualAutoSess32[1]<-mean(mydata[mydata$Sess==32,"ActualAuto.1."])
AvgActualAutoSess32[2]<-mean(mydata[mydata$Sess==32,"ActualAuto.2."])
AvgActualAutoSess32[3]<-mean(mydata[mydata$Sess==32,"ActualAuto.3."])
AvgActualAutoSess32[4]<-mean(mydata[mydata$Sess==32,"ActualAuto.4."])
AvgActualAutoSess32[5]<-mean(mydata[mydata$Sess==32,"ActualAuto.5."])
AvgActualAutoSess32[6]<-mean(mydata[mydata$Sess==32,"ActualAuto.6."])
AvgActualAutoSess32[7]<-mean(mydata[mydata$Sess==32,"ActualAuto.7."])
AvgActualAutoSess32[8]<-mean(mydata[mydata$Sess==32,"ActualAuto.8."])
AvgActualAutoSess32[9]<-mean(mydata[mydata$Sess==32,"ActualAuto.9."])
AvgActualAutoSess32[10]<-mean(mydata[mydata$Sess==32,"ActualAuto.10."])
AvgActualAutoSess32[11]<-mean(mydata[mydata$Sess==32,"ActualAuto.11."])
AvgActualAutoSess32[12]<-mean(mydata[mydata$Sess==32,"ActualAuto.12."])
AvgActualAutoSess32[13]<-mean(mydata[mydata$Sess==32,"ActualAuto.13."])
AvgActualAutoSess32[14]<-mean(mydata[mydata$Sess==32,"ActualAuto.14."])
AvgActualAutoSess32[15]<-mean(mydata[mydata$Sess==32,"ActualAuto.15."])
AvgActualAutoSess32[16]<-mean(mydata[mydata$Sess==32,"ActualAuto.16."])
AvgActualAutoSess32[17]<-mean(mydata[mydata$Sess==32,"ActualAuto.17."])
AvgActualAutoSess32[18]<-mean(mydata[mydata$Sess==32,"ActualAuto.18."])
AvgActualAutoSess32[19]<-mean(mydata[mydata$Sess==32,"ActualAuto.19."])
AvgActualAutoSess32[20]<-mean(mydata[mydata$Sess==32,"ActualAuto.20."])
AvgActualAutoSess32[21]<-mean(mydata[mydata$Sess==32,"ActualAuto.21."])
AvgActualAutoSess32[22]<-mean(mydata[mydata$Sess==32,"ActualAuto.22."])
AvgActualAutoSess32[23]<-mean(mydata[mydata$Sess==32,"ActualAuto.23."])
AvgActualAutoSess32[24]<-mean(mydata[mydata$Sess==32,"ActualAuto.24."])
AvgActualAutoSess32[25]<-mean(mydata[mydata$Sess==32,"ActualAuto.25."])

data <- data.frame(AvgActualFastSess32, AvgActualSlowSess32, AvgActualAutoSess32)
Sess32PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess32, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess32, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess32, name = 'Auto', mode = 'lines+markers')%>%
  layout(title = "Session 32 (Punishment 8)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess32PlotActual

Auto <- jitter(AvgActualAutoSess32)
Slow <- jitter(AvgActualSlowSess32)
Fast <- jitter(AvgActualFastSess32)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess32TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess32TriActual


Auto <- jitter(AvgActualAutoSess32)
Slow <- jitter(AvgActualSlowSess32)
Fast <- jitter(AvgActualFastSess32)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess32Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 32 - Punishment 8') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess32Tri2Actual





#Averages at each round by treatment






#Comparing within treatments

data <- data.frame(AvgActualFastSess1,AvgActualFastSess6,AvgActualFastSess7,AvgActualFastSess10,AvgActualFastSess14,AvgActualFastSess15)
FastPlotControl <- plot_ly(data, x = ~x, y = ~AvgActualFastSess1, name = 'C1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess6, name = 'C2', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess7, name = 'C3', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess10, name = 'C4', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess14, name = 'C5', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess15, name = 'C6', mode = 'lines+markers')%>%
  layout(title = "Control Sessions Fast",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
FastPlotControl



#Comparing across treatments

data <- data.frame(AvgActualFastSess1,AvgActualFastSess2,AvgActualFastSess3,AvgActualFastSess4,AvgActualFastSess5)
FastPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Fast - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
FastPlotActual


data <- data.frame(AvgActualSlowSess1,AvgActualSlowSess2,AvgActualSlowSess3,AvgActualSlowSess4,AvgActualSlowSess5)
SlowPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualSlowSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualSlowSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualSlowSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Slow - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
SlowPlotActual


data <- data.frame(AvgActualAutoSess1,AvgActualAutoSess2,AvgActualAutoSess3,AvgActualAutoSess4,AvgActualAutoSess5)
AutoPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualAutoSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualAutoSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualAutoSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Auto - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AutoPlotActual















#Plot for Session 24
AvgActualFastSess24<-numeric(25)
AvgActualFastSess24[1]<-mean(mydata[mydata$Sess==24,"ActualFast.1."])
AvgActualFastSess24[2]<-mean(mydata[mydata$Sess==24,"ActualFast.2."])
AvgActualFastSess24[3]<-mean(mydata[mydata$Sess==24,"ActualFast.3."])
AvgActualFastSess24[4]<-mean(mydata[mydata$Sess==24,"ActualFast.4."])
AvgActualFastSess24[5]<-mean(mydata[mydata$Sess==24,"ActualFast.5."])
AvgActualFastSess24[6]<-mean(mydata[mydata$Sess==24,"ActualFast.6."])
AvgActualFastSess24[7]<-mean(mydata[mydata$Sess==24,"ActualFast.7."])
AvgActualFastSess24[8]<-mean(mydata[mydata$Sess==24,"ActualFast.8."])
AvgActualFastSess24[9]<-mean(mydata[mydata$Sess==24,"ActualFast.9."])
AvgActualFastSess24[10]<-mean(mydata[mydata$Sess==24,"ActualFast.10."])
AvgActualFastSess24[11]<-mean(mydata[mydata$Sess==24,"ActualFast.11."])
AvgActualFastSess24[12]<-mean(mydata[mydata$Sess==24,"ActualFast.12."])
AvgActualFastSess24[13]<-mean(mydata[mydata$Sess==24,"ActualFast.13."])
AvgActualFastSess24[14]<-mean(mydata[mydata$Sess==24,"ActualFast.14."])
AvgActualFastSess24[15]<-mean(mydata[mydata$Sess==24,"ActualFast.15."])
AvgActualFastSess24[16]<-mean(mydata[mydata$Sess==24,"ActualFast.16."])
AvgActualFastSess24[17]<-mean(mydata[mydata$Sess==24,"ActualFast.17."])
AvgActualFastSess24[18]<-mean(mydata[mydata$Sess==24,"ActualFast.18."])
AvgActualFastSess24[19]<-mean(mydata[mydata$Sess==24,"ActualFast.19."])
AvgActualFastSess24[20]<-mean(mydata[mydata$Sess==24,"ActualFast.20."])
AvgActualFastSess24[21]<-mean(mydata[mydata$Sess==24,"ActualFast.21."])
AvgActualFastSess24[22]<-mean(mydata[mydata$Sess==24,"ActualFast.22."])
AvgActualFastSess24[23]<-mean(mydata[mydata$Sess==24,"ActualFast.23."])
AvgActualFastSess24[24]<-mean(mydata[mydata$Sess==24,"ActualFast.24."])
AvgActualFastSess24[25]<-mean(mydata[mydata$Sess==24,"ActualFast.25."])
AvgActualSlowSess24<-numeric(25)
AvgActualSlowSess24[1]<-mean(mydata[mydata$Sess==24,"ActualSlow.1."])
AvgActualSlowSess24[2]<-mean(mydata[mydata$Sess==24,"ActualSlow.2."])
AvgActualSlowSess24[3]<-mean(mydata[mydata$Sess==24,"ActualSlow.3."])
AvgActualSlowSess24[4]<-mean(mydata[mydata$Sess==24,"ActualSlow.4."])
AvgActualSlowSess24[5]<-mean(mydata[mydata$Sess==24,"ActualSlow.5."])
AvgActualSlowSess24[6]<-mean(mydata[mydata$Sess==24,"ActualSlow.6."])
AvgActualSlowSess24[7]<-mean(mydata[mydata$Sess==24,"ActualSlow.7."])
AvgActualSlowSess24[8]<-mean(mydata[mydata$Sess==24,"ActualSlow.8."])
AvgActualSlowSess24[9]<-mean(mydata[mydata$Sess==24,"ActualSlow.9."])
AvgActualSlowSess24[10]<-mean(mydata[mydata$Sess==24,"ActualSlow.10."])
AvgActualSlowSess24[11]<-mean(mydata[mydata$Sess==24,"ActualSlow.11."])
AvgActualSlowSess24[12]<-mean(mydata[mydata$Sess==24,"ActualSlow.12."])
AvgActualSlowSess24[13]<-mean(mydata[mydata$Sess==24,"ActualSlow.13."])
AvgActualSlowSess24[14]<-mean(mydata[mydata$Sess==24,"ActualSlow.14."])
AvgActualSlowSess24[15]<-mean(mydata[mydata$Sess==24,"ActualSlow.15."])
AvgActualSlowSess24[16]<-mean(mydata[mydata$Sess==24,"ActualSlow.16."])
AvgActualSlowSess24[17]<-mean(mydata[mydata$Sess==24,"ActualSlow.17."])
AvgActualSlowSess24[18]<-mean(mydata[mydata$Sess==24,"ActualSlow.18."])
AvgActualSlowSess24[19]<-mean(mydata[mydata$Sess==24,"ActualSlow.19."])
AvgActualSlowSess24[20]<-mean(mydata[mydata$Sess==24,"ActualSlow.20."])
AvgActualSlowSess24[21]<-mean(mydata[mydata$Sess==24,"ActualSlow.21."])
AvgActualSlowSess24[22]<-mean(mydata[mydata$Sess==24,"ActualSlow.22."])
AvgActualSlowSess24[23]<-mean(mydata[mydata$Sess==24,"ActualSlow.23."])
AvgActualSlowSess24[24]<-mean(mydata[mydata$Sess==24,"ActualSlow.24."])
AvgActualSlowSess24[25]<-mean(mydata[mydata$Sess==24,"ActualSlow.25."])
AvgActualAutoSess24<-numeric(25)
AvgActualAutoSess24[1]<-mean(mydata[mydata$Sess==24,"ActualAuto.1."])
AvgActualAutoSess24[2]<-mean(mydata[mydata$Sess==24,"ActualAuto.2."])
AvgActualAutoSess24[3]<-mean(mydata[mydata$Sess==24,"ActualAuto.3."])
AvgActualAutoSess24[4]<-mean(mydata[mydata$Sess==24,"ActualAuto.4."])
AvgActualAutoSess24[5]<-mean(mydata[mydata$Sess==24,"ActualAuto.5."])
AvgActualAutoSess24[6]<-mean(mydata[mydata$Sess==24,"ActualAuto.6."])
AvgActualAutoSess24[7]<-mean(mydata[mydata$Sess==24,"ActualAuto.7."])
AvgActualAutoSess24[8]<-mean(mydata[mydata$Sess==24,"ActualAuto.8."])
AvgActualAutoSess24[9]<-mean(mydata[mydata$Sess==24,"ActualAuto.9."])
AvgActualAutoSess24[10]<-mean(mydata[mydata$Sess==24,"ActualAuto.10."])
AvgActualAutoSess24[11]<-mean(mydata[mydata$Sess==24,"ActualAuto.11."])
AvgActualAutoSess24[12]<-mean(mydata[mydata$Sess==24,"ActualAuto.12."])
AvgActualAutoSess24[13]<-mean(mydata[mydata$Sess==24,"ActualAuto.13."])
AvgActualAutoSess24[14]<-mean(mydata[mydata$Sess==24,"ActualAuto.14."])
AvgActualAutoSess24[15]<-mean(mydata[mydata$Sess==24,"ActualAuto.15."])
AvgActualAutoSess24[16]<-mean(mydata[mydata$Sess==24,"ActualAuto.16."])
AvgActualAutoSess24[17]<-mean(mydata[mydata$Sess==24,"ActualAuto.17."])
AvgActualAutoSess24[18]<-mean(mydata[mydata$Sess==24,"ActualAuto.18."])
AvgActualAutoSess24[19]<-mean(mydata[mydata$Sess==24,"ActualAuto.19."])
AvgActualAutoSess24[20]<-mean(mydata[mydata$Sess==24,"ActualAuto.20."])
AvgActualAutoSess24[21]<-mean(mydata[mydata$Sess==24,"ActualAuto.21."])
AvgActualAutoSess24[22]<-mean(mydata[mydata$Sess==24,"ActualAuto.22."])
AvgActualAutoSess24[23]<-mean(mydata[mydata$Sess==24,"ActualAuto.23."])
AvgActualAutoSess24[24]<-mean(mydata[mydata$Sess==24,"ActualAuto.24."])
AvgActualAutoSess24[25]<-mean(mydata[mydata$Sess==24,"ActualAuto.25."])

FineCostSess24<-numeric(25)
FineCostSess24[1]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.1."])
FineCostSess24[2]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.2."])
FineCostSess24[3]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.3."])
FineCostSess24[4]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.4."])
FineCostSess24[5]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.5."])
FineCostSess24[6]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.6."])
FineCostSess24[7]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.7."])
FineCostSess24[8]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.8."])
FineCostSess24[9]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.9."])
FineCostSess24[10]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.10."])
FineCostSess24[11]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.11."])
FineCostSess24[12]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.12."])
FineCostSess24[13]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.13."])
FineCostSess24[14]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.14."])
FineCostSess24[15]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.15."])
FineCostSess24[16]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.16."])
FineCostSess24[17]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.17."])
FineCostSess24[18]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.18."])
FineCostSess24[19]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.19."])
FineCostSess24[20]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.20."])
FineCostSess24[21]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.21."])
FineCostSess24[22]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.22."])
FineCostSess24[23]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.23."])
FineCostSess24[24]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.24."])
FineCostSess24[25]<-mean(mydata[mydata$Sess==24,"FineContributionHistory.25."])

data <- data.frame(AvgActualFastSess24, AvgActualSlowSess24, AvgActualAutoSess24,FineCostSess24)
Sess24PlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess24, name = 'Fast', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess24, name = 'Slow', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess24, name = 'Auto', mode = 'lines+markers')%>%
  add_trace(y = ~FineCostSess24, name = 'FineCost', mode = 'lines+markers')%>%
  layout(title = "Session 24 (Punishment 2.5) - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
Sess24PlotActual

Auto <- jitter(AvgActualAutoSess24)
Slow <- jitter(AvgActualSlowSess24)
Fast <- jitter(AvgActualFastSess24)
Round <- c('Round 1','Round 2','Round 3','Round 4','Round 5','Round 6',
           'Round 7','Round 8','Round 9','Round 10','Round 11','Round 12','Round 13','Round 14','Round 15',
           'Round 16','Round 17','Round 18','Round 19','Round 20','Round 21','Round 22','Round 23','Round 24',
           'Round 25')
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
df <- data.frame(Auto,Slow,Fast,Round,colour)
axis <- function(title) {
  list(
    title = title,
    titlefont = list(
      size = 15
    ),
    tickfont = list(
      size = 10
    ),
    tickcolor = 'rgba(0,0,0,0)',
    ticklen = 2
  )
}

Sess24TriActual <- df %>% 
  plot_ly() %>%
  add_trace(
    type = 'scatterternary',
    mode = 'markers',
    a = ~Auto,
    b = ~Slow,
    c = ~Fast,
    text = ~Round,
    marker = list( 
      symbol = 100,
      color = ~colour,
      size = 5,
      line = list('width' = 2)
    )
  ) %>% 
  layout(
    #title = "Simple Ternary Plot with Markers",
    ternary = list(
      sum = 100,
      aaxis = axis('Auto'),
      baxis = axis('Slow'),
      caxis = axis('Fast')
    )
  )
Sess24TriActual


Auto <- jitter(AvgActualAutoSess24)
Slow <- jitter(AvgActualSlowSess24)
Fast <- jitter(AvgActualFastSess24)
Round <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)
#colour <- c('#000000','#080808','#101010','#181818','#202020','#282828','#303030','#383838','#404040','#484848','#505050','#585858','#606060','#686868','#707070','#787878','#808080','#888888','#909090','#989898','#A0A0A0','#A8A8A8','#B0B0B0','#B8B8B8','#C0C0C0')
#colour <- c('#000000','#000000','#000000','#000000','#000000','#0000CD','#0000CD','#0000CD','#0000CD','#0000CD','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#1E90FF','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#87CEEB','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6','#B0E0E6')
#df <- data.frame(Auto,Slow,Fast,Round,colour)
df <- data.frame(Auto,Slow,Fast,Round)
Sess24Tri2Actual <- ggtern(data = df, aes(x = Slow, y = Auto, z = Fast)) +
  geom_point(aes(fill = Round), size = 3, shape = 21, color = 'black') +
  labs(title='Session 5 - Compulsion - Actual') +
  labs(fill = 'Round') +
  theme_rgbw()+
  scale_fill_gradient(low = '#000066', high = '#FFFFFF') +
  #scale_size_continuous(range = c(2.5, 7.5)) +
  theme(legend.position = c(0.82,.8),
        legend.justification = c(1, 1))+ theme_hidegrid_minor()+theme_noarrows()+
  theme(plot.title = element_text(hjust = 0.5))

Sess24Tri2Actual


#Comparing across treatments

data <- data.frame(AvgActualFastSess1,AvgActualFastSess2,AvgActualFastSess3,AvgActualFastSess4,AvgActualFastSess5)
FastPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualFastSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualFastSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualFastSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Fast - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
FastPlotActual


data <- data.frame(AvgActualSlowSess1,AvgActualSlowSess2,AvgActualSlowSess3,AvgActualSlowSess4,AvgActualSlowSess5)
SlowPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualSlowSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualSlowSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualSlowSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualSlowSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Slow - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
SlowPlotActual


data <- data.frame(AvgActualAutoSess1,AvgActualAutoSess2,AvgActualAutoSess3,AvgActualAutoSess4,AvgActualAutoSess5)
AutoPlotActual <- plot_ly(data, x = ~x, y = ~AvgActualAutoSess1, name = 'Control 1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess2, name = 'Comp. 1', mode = 'lines+markers') %>%
  add_trace(y = ~AvgActualAutoSess3, name = 'Assoc. 1', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualAutoSess4, name = 'Assoc. 2', mode = 'lines+markers')%>%
  add_trace(y = ~AvgActualAutoSess5, name = 'Comp. 2', mode = 'lines+markers')%>%
  layout(title = "Sessions 1-5 Auto - Actual",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AutoPlotActual

#END OF Actual


#AvgGuessFast is a matrix (session #, round #)
AvgGuessFast<- matrix(nrow=max(mydata$Sess), ncol=25)
count<-1
for(j in 1:25){
  for(i in 1:obs){if(mydata$Sess[j]==j){
    AvgGuessFast[count,1]<-mean(mydata[mydata$Sess==count,"GuessFast.1."])
    AvgGuessFast[count,2]<-mean(mydata[mydata$Sess==count,"GuessFast.2."])
    AvgGuessFast[count,3]<-mean(mydata[mydata$Sess==count,"GuessFast.3."])
    AvgGuessFast[count,4]<-mean(mydata[mydata$Sess==count,"GuessFast.4."])
    AvgGuessFast[count,5]<-mean(mydata[mydata$Sess==count,"GuessFast.5."])
    AvgGuessFast[count,6]<-mean(mydata[mydata$Sess==count,"GuessFast.6."])
    AvgGuessFast[count,7]<-mean(mydata[mydata$Sess==count,"GuessFast.7."])
    AvgGuessFast[count,8]<-mean(mydata[mydata$Sess==count,"GuessFast.8."])
    AvgGuessFast[count,9]<-mean(mydata[mydata$Sess==count,"GuessFast.9."])
    AvgGuessFast[count,10]<-mean(mydata[mydata$Sess==count,"GuessFast.10."])
    AvgGuessFast[count,11]<-mean(mydata[mydata$Sess==count,"GuessFast.11."])
    AvgGuessFast[count,12]<-mean(mydata[mydata$Sess==count,"GuessFast.12."])
    AvgGuessFast[count,13]<-mean(mydata[mydata$Sess==count,"GuessFast.13."])
    AvgGuessFast[count,14]<-mean(mydata[mydata$Sess==count,"GuessFast.14."])
    AvgGuessFast[count,15]<-mean(mydata[mydata$Sess==count,"GuessFast.15."])
    AvgGuessFast[count,16]<-mean(mydata[mydata$Sess==count,"GuessFast.16."])
    AvgGuessFast[count,17]<-mean(mydata[mydata$Sess==count,"GuessFast.17."])
    AvgGuessFast[count,18]<-mean(mydata[mydata$Sess==count,"GuessFast.18."])
    AvgGuessFast[count,19]<-mean(mydata[mydata$Sess==count,"GuessFast.19."])
    AvgGuessFast[count,20]<-mean(mydata[mydata$Sess==count,"GuessFast.20."])
    AvgGuessFast[count,21]<-mean(mydata[mydata$Sess==count,"GuessFast.21."])
    AvgGuessFast[count,22]<-mean(mydata[mydata$Sess==count,"GuessFast.22."])
    AvgGuessFast[count,23]<-mean(mydata[mydata$Sess==count,"GuessFast.23."])
    AvgGuessFast[count,24]<-mean(mydata[mydata$Sess==count,"GuessFast.24."])
    AvgGuessFast[count,25]<-mean(mydata[mydata$Sess==count,"GuessFast.25."])
    count<-count+1
  }}
  count<-1
}

#To see the average guess fast over all rounds in session 30
AvgGuessFast[30,]
plot(AvgGuessFast[1,])
#Graph of the average guess of fast in each round in each control session
data <- data.frame(AvgGuessFast[1,], AvgGuessFast[6,], AvgGuessFast[7,], AvgGuessFast[10,], AvgGuessFast[14,], AvgGuessFast[15,], AvgGuessFast[20,], AvgGuessFast[26,])
data
AvgGuessFastPlotControl <- plot_ly(data, x = ~x, y = ~AvgGuessFast[1,], name = 'FastC1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[6,], name = 'FastC2', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[7,], name = 'FastC3', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[10,], name = 'FastC4', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[14,], name = 'FastC5', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[15,], name = 'FastC6', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[20,], name = 'FastC7', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[26,], name = 'FastC8', mode = 'lines+markers')%>%
  layout(title = "AvgGuessFast (Control sessions)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AvgGuessFastPlotControl


#Graph of the average guess of fast in each round in each Fine session
data <- data.frame(AvgGuessFast[2,], AvgGuessFast[5,], AvgGuessFast[8,], AvgGuessFast[12,], AvgGuessFast[16,], AvgGuessFast[18,], AvgGuessFast[22,], AvgGuessFast[24,])
data
AvgGuessFastPlotFine <- plot_ly(data, x = ~x, y = ~AvgGuessFast[2,], name = 'FastF1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[5,], name = 'FastF2', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[8,], name = 'FastF3', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[12,], name = 'FastF4', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[16,], name = 'FastF5', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[18,], name = 'FastF6', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[22,], name = 'FastF7', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[24,], name = 'FastF8', mode = 'lines+markers')%>%
  layout(title = "AvgGuessFast (Fine sessions)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AvgGuessFastPlotFine

#Graph of the average guess of fast in each round in each Association session
data <- data.frame(AvgGuessFast[3,], AvgGuessFast[4,], AvgGuessFast[9,], AvgGuessFast[11,], AvgGuessFast[13,], AvgGuessFast[17,], AvgGuessFast[19,], AvgGuessFast[21,])
data
AvgGuessFastPlotAssoc <- plot_ly(data, x = ~x, y = ~AvgGuessFast[3,], name = 'FastA1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[4,], name = 'FastA2', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[9,], name = 'FastA3', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[11,], name = 'FastA4', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[13,], name = 'FastA5', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[17,], name = 'FastA6', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[19,], name = 'FastA7', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[21,], name = 'FastA8', mode = 'lines+markers')%>%
  layout(title = "AvgGuessFast (Assoc. sessions)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AvgGuessFastPlotAssoc

#Graph of the average guess of fast in each round in each Punishment session
data <- data.frame(AvgGuessFast[23,], AvgGuessFast[25,], AvgGuessFast[27,], AvgGuessFast[28,], AvgGuessFast[29,], AvgGuessFast[30,], AvgGuessFast[31,], AvgGuessFast[32,])
data
AvgGuessFastPlotPun <- plot_ly(data, x = ~x, y = ~AvgGuessFast[23,], name = 'FastP1', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[25,], name = 'FastP2', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFast[27,], name = 'FastP3', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[28,], name = 'FastP4', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[29,], name = 'FastP5', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[30,], name = 'FastP6', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[31,], name = 'FastP7', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFast[32,], name = 'FastP8', mode = 'lines+markers')%>%
  layout(title = "AvgGuessFast (Punishment sessions)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AvgGuessFastPlotPun


#AvgGuessFastControl is the average guess for Fast in all control sessions by round matrix (session #, round #)
AvgGuessFastControl<- numeric(25)
AvgGuessFastFine<- numeric(25)
AvgGuessFastAssoc<- numeric(25)
AvgGuessFastPun<- numeric(25)
count<-1
for(j in 1:25){
  AvgGuessFastControl[count]<-(AvgGuessFast[1,count]+AvgGuessFast[6,count]+AvgGuessFast[7,count]+AvgGuessFast[10,count]+AvgGuessFast[14,count]+AvgGuessFast[15,count]+AvgGuessFast[20,count]+AvgGuessFast[26,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgGuessFastFine[count]<-(AvgGuessFast[2,count]+AvgGuessFast[5,count]+AvgGuessFast[8,count]+AvgGuessFast[12,count]+AvgGuessFast[16,count]+AvgGuessFast[18,count]+AvgGuessFast[22,count]+AvgGuessFast[24,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgGuessFastAssoc[count]<-(AvgGuessFast[3,count]+AvgGuessFast[4,count]+AvgGuessFast[9,count]+AvgGuessFast[11,count]+AvgGuessFast[13,count]+AvgGuessFast[17,count]+AvgGuessFast[19,count]+AvgGuessFast[21,count])/8
  count<-count+1
}
count<-1
for(j in 1:25){
  AvgGuessFastPun[count]<-(AvgGuessFast[23,count]+AvgGuessFast[25,count]+AvgGuessFast[27,count]+AvgGuessFast[28,count]+AvgGuessFast[29,count]+AvgGuessFast[30,count]+AvgGuessFast[31,count]+AvgGuessFast[32,count])/8
  count<-count+1
}


#Graph of the average guess of fast in each Treatment
data <- data.frame(AvgGuessFastControl, AvgGuessFastFine,AvgGuessFastAssoc,AvgGuessFastPun,x)
x<-c(1:25)
data
AvgGuessFastPlotTreat <- plot_ly(data, x = ~x, y = ~AvgGuessFastControl, name = 'FastControl', type = 'scatter', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFastFine, name = 'FastFine', mode = 'lines+markers') %>%
  add_trace(y = ~AvgGuessFastAssoc, name = 'FastAssoc', mode = 'lines+markers')%>%
  add_trace(y = ~AvgGuessFastPun, name = 'FastPun', mode = 'lines+markers')%>%
  layout(title = "AvgGuessFast (Punishment sessions)",
         xaxis = list(range = c(0, 25),title = "Round"),
         yaxis = list(range = c(0, 100),title = "Proportion"))
AvgGuessFastPlotTreat

#EXAMPLE Player A won 17 out of 25 games while player B won 8 out of 20 - is there a significant difference between both ratios?
#fisher.test(matrix(c(17, 25-17, 8, 20-8), ncol=2))

#ME Slow contributed 61 out of 439 times while Auto contributed 62 out of 590 times - is there a significant difference between both ratios?
fisher.test(matrix(c(61, 439-61, 86, 825-86), ncol=2))

#Chi squared tests for table 3 Nov 1 2018
tblc = table(AutoFastSlowC)
tblf = table(AutoFastSlowF)
tbla = table(AutoFastSlowA)
tblp = table(AutoFastSlowP)


tbl = data.frame(tblc, tblf, tbla, tblp) 
tbl<- tbl[,-1]
tbl<- tbl[,-2]
tbl<- tbl[,-3]
tbl<- tbl[,-4]

chisq.test(tbl) 